Re: [PHP] Regex to catch <p>s

[email protected] (Shawn McKenzie)
Newsgroups php.general
Message-ID <[email protected]>
Ryan S wrote:
> 
> <clip>
>>  To say I suck at regex is an understatement so really need any help I can get on this, I have a page of text with different html tags in them, but each "block" of text has a <p> or a < class="something"> tag... anybody have any regex that will catch each of these paragraphs and put then into an array
> 
> 
> If you're using php5 you can use DOM's getElementsByTagName.
> 
> If you still think you need to do some sort of regex it is possible
> but it will be buggy at best.
> 
> 
> </clip>
> 
> Nope, need a regex... guess I have no choice, either chancy regex or nothing... I know for a fact that the first paragraph tag wont contain a class, and for the <p> tags that contain a class="blah" does it matter that i know exactly what the classname is?
> 
> 
> 
>       ____________________________________________________________________________________
> Be a better friend, newshound, and 
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

preg_match_all('|<p[^>]*>(.*)</p>|Ui', $myText, $myArray);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.