Using preg_match_all
is it possible to match elements within a parent that has a specific class name?
For example I have this HTML markup:
<div class="red lorem-ipsum>
<a href="#">Some link</a>
</div>
<div class="red>
<a href="#">Some link</a>
</div>
<div class="something red lorem-ipsum>
<a href="#">Some link</a>
</div>
Can I match each <a>
that's within a parent with class name red
?
I tried this but it does not work:
~(?:<div class="red">|\G)\s*<a [^>]+>~i