Re: Re: strip comments from HTML?

From: Date: Thu, 06 May 2004 19:11:55 +0000
Subject: Re: Re: strip comments from HTML?
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-185549@lists.php.net to get a copy of this message
* Thus wrote Paul Chvostek (paul+php@it.ca): > On Thu, May 06, 2004 at 11:26:34AM -0400, Rob Ellis wrote: > > > > > > $text = ereg_replace("<!--[^>]*-->","",$text); > > > > you can make the .* less greedy... > > > > $text = preg_replace('/<!--.*?-->/', '', $text); > > Interestingly, from a shell: > > $ text='one <!-- bleh --> two\nthree <!-- blarg -->four\n' > $ printf "$text" | sed -E 's/<!--([^-][^-]?[^>]?)*-->//g' > one two > three four > > which is the same behaviour as PHP. But that still doesn't cover > multi-line. PHP's ereg support is supposed to, but doesn't work with > this particular substitution: > > $text="one <!--bleh\nblarg -> two\n"; > print ereg_replace("<!--([^-][^-]?[^>]?)*-->", "",$text); Because your missing a - $text="one <!--bleh\nblarg --> two\n"; ^^^ Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#185549) next »