haystack:
<h2 >a · · ·
</h2>
<div class="indent">
aaaa
</div>
<h2 >b · · ·
</h2>
<div class="indent">
bbbb
</div>
pattern I used:
#<h2[^>]*>(a|b)(?!</h2>)[\s\S]*</h2><div class="indent">((?!</div>)[\s\S]+)</div>#
this pattern only matches the first h2 content(e.g. a · · ·
) and the content in last div(e.g. bbbb
)
but I whan it to match all content in the h2 and div to make an one to one map(e.g. a · · ·
=>aaaa
,b · · ·
=>bbbb
), how do I do this?