I'm trying to extract the words within the <li>
</li>
tags below. My regex is working well, but only giving me the first <li>
, Lorem ipsum...
I'm reasonably new to regex, and I am aware it would be likely more reliable to do this by traversing the DOM, but in this case regex is prefered. Any ideas what I need to change to get all the results, instead of just the one?
/<div class="foo-bar">[\s\S]+<ul>[\s\S]*?(<li>([\s\S]*?)<\/li>)+[\s\S]*?<\/ul>/
<div class="foo-bar">
<!-- Other junk -->
<ul>
<li>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</li>
<li>
Vestibulum iaculis nibh ac orci imperdiet ultrices.
</li>
<li>
Fusce neque lacus, feugiat eget sapien eget, ullamcorper rutrum mauris.
</li>
<li>
Maecenas in ipsum consectetur, finibus ex et, condimentum turpis.
</li>
</ul>
<!-- Other junk -->
</div>