At 5:19 PM -0400 8/2/01, Jack Dempsey wrote:
>$str = preg_replace("<p.*?>", " ",$str);

        $str = eregi_replace('<p[^>]*>', ' ', $str);

This matches <p (or <P), followed by any character string that 
DOESN'T include a >, then the trailing >.

Preg functions are faster, though. And, if you're interested in 
little speed tweaks, use single quotes - ' - rather than double 
quotes - " - here. With double quotes, PHP searches the quoted string 
for variables or escape characters to replace.


>-----Original Message-----
>From: Julian Simpson [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, August 02, 2001 5:16 PM
>Subject: [PHP] another REGEX question
>I have a string can look like either of the following:
><p>some stuff</p>
><p align = "left">some stuff</p>
>I want to use eregi_replace to take out the first p tag whether it be
><p> or <p align......> with a space
>I assumed that $str = eregi_replace ("<p.*>", " ",$str);
>but it matches the entire string and thus turns the whole string into
>one space.
>aparently regex will match the biggest possible match rather than the
>my question is how do i get it to match the smallest.
>thanx in advance..

+------ Factoid: Of the 100 largest economies in the world, 51 are ------+
| Steve Edberg                           University of California, Davis |
| [EMAIL PROTECTED]                               Computer Consultant |
|         |
+--- corporations ------ ---+

PHP General Mailing List (
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to