Forget my first attempt, using the e modifier and another preg_replace
is much better.
$return = preg_replace('!<h(\d)>(.*?)</h\1>!ie',
'preg_replace("!<br[^>]*>!i", "", "$1")', $originalText);
On Sun, 1 Aug 2004 13:39:49 -0700, Justin Patrin <[EMAIL PROTECTED]> wrote:
> On Sun, 1 Aug 2004 06:27:51 -0700 (PDT), Kathleen Ballard
> <[EMAIL PROTECTED]> 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--
>
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php