0

Hello,

I am currently passing some HTML through to preg_match and I want to access all the HTML between two tags, however as the same tags may be repeated afterwards my current expression isn't working. For example, my expression at the moment is

<li>(.*)</li>

But as the HTML is like this:

<li><!-- A bunch of HTML in here --></li>
<li><!-- More HTML in here --></li>

It picks up everything between the first <li> and the very last </li>

I've been trying to think of a means of solving this for hours but I am well and truly stuck, does anyone have any idea on how I may be able to overcome this issue?

Thanks

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by pritaeas
0

pritaeas, that works perfectly! Will the lazy quantifier always attempt to cut the match as short as possible? i.e. is it looking for an instance of </li> and when doing so ending the match?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.