I have a sample multi line string where in I have to get all the div tags and contents between them where in the p tag is not equal to a specific id
var str="<div>
<p id=\"a\">Sample sentence</p>
</div>
<div>
<p id=\"b\">Sample sentence 2</p>
</div>"
The regex that I was using was too greedy, I only need to match the 2nd div tag and its content but it is also capturing the div tag from above. Here is my regex:
<div>[\s\S]*<p id="b">[\s\S]*<\/div>
for the regex I used it is capturing the entire string but I just want to capture:
<div>
<p id="b">Sample sentence 2</p>
</div>
any regex guru out there that can help me out with this?