Re: stripping

From: Date: Thu, 10 Apr 2003 11:42:11 +0000
Subject: Re: stripping
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143316@lists.php.net to get a copy of this message
On Thursday 10 April 2003 17:07, Jack Dempsey wrote: > ok, so i don't have easy access to php at the moment, but here's the code > in perl: > > $text = > "alksdjflskjdf<blockquote>thi\nsisljf\nlasjdflajsdflj</blockquote>\nalsjfal >; skjf\n"; > > print "$text\n\n"; > > $text =~ s|<blockquote>.*?</blockquote>||gis; > > print $text; > > > so, the important part, the regex, is easy enough to put back into > php...basically, you want it to be case insensitive, repeat as many matches > as possible, and for the . to match \n as well... In PHP it would something like: ------------------------------------ $doo = "[quote] [b]some text...[/b] <blockquote> <b>some text...</b> some more text.... </blockquote> some more text.... [/quote]"; $dah = preg_replace('|<blockquote>.*</blockquote>|sim', '', $doo); echo "$dah"; ------------------------------------ -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* Friends, n.: People who borrow your books and set wet glasses on them. People who know you well, but like you anyway. */

« previous php.general (#143316) next »