Hi!
For example, there is some part of HTML file:


<p class="results">
<a class="result_doctype"></a>
<a class="result_url" href="http://www.phpbuilder.com/">
</p>


And I want to get the string between <p class="results"> and </p>, so my script is:


preg_match('/<p class=\"results\">(.*)<\/p>/', $contents, $matches);


But it does not work!
I look for some doc, and find "." cannot find string with new line.
So how can I use preg_match with string blocks?

Thanks!
Mike

    I guess you missed this page :rolleyes:
    You'll also need to make the regex un-greedy (there's a modifier for that as well) or else you'll get unexpected results on strings with more than one p element pair.

    HTH
    Bubble

      Write a Reply...