NYCPHP Meetup

NYPHP.org

[nycphp-talk] Regex for P Elements

Randal Rust randalrust at gmail.com
Wed Jan 12 09:06:44 EST 2011


On Wed, Jan 12, 2011 at 8:55 AM, Dan Cech <dcech at phpwerx.net> wrote:

> Shouldn't the expression be:
>
> $blockpattern='/<p[^>]*>.*?<\/p>/';
>
> I removed the * after the first p.

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.

-- 
Randal Rust
R.Squared Communications
www.r2communications.com
www.facebook.com/r2communications
614-370-0036



More information about the talk mailing list