NYCPHP Meetup

NYPHP.org

[nycphp-talk] Regex for P Elements

Donald J. Organ IV dorgan at donaldorgan.com
Wed Jan 12 09:00:14 EST 2011


Try:


$blockpattern='/<p*[^>]>.*?/m';


Notice the m after the last /   this says it can span multiple lines....


----- Original Message -----
From: "Randal Rust" <randalrust at gmail.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Wednesday, January 12, 2011 9:06:44 AM
Subject: Re: [nycphp-talk] Regex for P Elements

Trying to work my way through the expression, to see where it fails.
If I use this:

$blockpattern='/<p*[^>]*>.*?/';

It returns 116 matches, but if I take out that extra *, as you suggested Dan...

$blockpattern='/<p*[^>]>.*?/';

...I get 33 matches, which is correct.

However, when I add the rest of the expression, like this...

$blockpattern='/<p*[^>]>.*?<\/p>/';

I still get 0 results from preg_match_all.



More information about the talk mailing list