Reputation: 551
Can anybody help me with a function in php using regex to return all founded sub strings between two delimiters.
expmple :
<p class="mn"><a href="123517/2882"> Hi all 5 </a>
<p class="mn"><a href="123518/2662"> Hi all 6 </a>
<p class="mn"><a href="123519/2552"> Hi all 55 </a>
<p class="mn"><a href="1235100/7722"> Hi all 15</a>
I need to get all substrings between <p class="mn"><a href="
and ">
using regex php function.
I tried some methods here but I can not handle regex syntax rightly, so I need a help with regex syntax and how to use it.
thanks
Upvotes: 1
Views: 1987
Reputation: 7525
In the specific sense, try
preg_match_all('@<p class="mn"><a href="(.+?)">@', $str, $m);
In the general sense, parse the HTML with a library and use XPath.
Upvotes: 5