Re: regex help

From: Date: Sun, 01 Aug 2004 20:39:49 +0000
Subject: Re: regex help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-192447@lists.php.net to get a copy of this message
On Sun, 1 Aug 2004 06:27:51 -0700 (PDT), Kathleen Ballard <klb5770@yahoo.com> wrote: > I am at the tailend of a project that involves moving > legacy data from one dbms to another. The client has > added a new requirement to the data manipulation that > is required. I need to remove all <br /> tags (there > may be more that one) that appear within all <h*> > tags. > > I am not very familiar with building regular > expressions, but I see this as a 2 part process. > First, to grab <h*> tags, and second, to strip the > br's. > > I can grab the beginning of the tag easily, but my > expressions grab too much. > > Also, I am not sure how to remove the br's. > > Any help would be appreciated. I have tried to find > similar examples, but without any luck. Also, php5 is > not an option at this point. > $text = preg_replace('!(<h\d[^>]*>.*?)<br/>(.*?</h\d>)!is', '\1\2', $text); You may also have to do this several times as this will only get one br per <h> tag. $newText = $text; do { $text = $newText; $newText = preg_replace('!(<h\d[^>]*>.*?)<br/>(.*?</h\d>)!is', '\1\2', $text); } while($text != $newText); > Kathleen > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.general (#192447) next »