Re: Re: strip comments from HTML?

From: Date: Fri, 07 May 2004 14:37:02 +0000
Subject: Re: Re: strip comments from HTML?
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-185622@lists.php.net to get a copy of this message
On Thu, May 06, 2004 at 11:48:36PM -0400, Paul Chvostek wrote: > On Thu, May 06, 2004 at 07:11:55PM +0000, Curt Zirzow wrote: > > > > > > $text="one <!--bleh\nblarg -> two\n"; > > > print ereg_replace("<!--([^-][^-]?[^>]?)*-->", > > > "",$text); > > > > Because your missing a - > > $text="one <!--bleh\nblarg --> two\n"; > > /me applies mallet to head > > % php -r '$text="one <!--bleh\nblarg --> two\n"; print > ereg_replace("<!--([^-][^-]?[^>]?)*-->", "",$text);' > one two > > whee, it works! :) > you're still missing things like <!------------ START ------------->... don't know how you can get around that with ereg. also preg_replace('/<!--.*?-->/s', ...) is much faster. :-) - rob

« previous php.general (#185622) next »