Hello I would like to use preg_match in PHP to parse the "Desired text" out of the following from a html document
<p class="review"> Desired text </p>
Ordinarily I would use simple_html_dom for such things but on this occasion it cannot be used (the above element doesn't appear in every desired div tag so I'm forced to use this approach to keep track of exactly when it doesn't appear and then adjust my array from simple_html_dom accordingly).
Anyway, this would solve my problem.
Thanks so much.
if you want to return multiple matches then need to use preg_match_all(). You then loop through the second result group ($match[1]) to get just the content between tags.
What if the string you're matching has multiple lines and is:
That pattern would match once, and the match would be everything in the string.
I think a better pattern is: