I have a requirement of removing a specific div tag with a unique id from the string and retain content. I want to strip out the div with a id="anchorWrap" as shown belove.
<div class="stl_ stl_02">
<div class="stl_view">
<div class="stl_05 stl_06">
<div class="stl_01" style="left:18.0477em;top:1.7673em;"><span class="stl_15 stl_08 stl_16" style="word-spacing:0.1552em;"><div style="background:#bba61c; display: inline-block;" id="anchorWrap">Chief Complaint </div></span></div>
<div class="stl_01" style="left:1.6em;top:17.4546em;"><span class="stl_17 stl_08 stl_18" style="word-spacing:0.0066em;">This is a 37 y.o. WM who presents with </span></div>
<div class="stl_01" style="left:1.6em;top:21.0546em;"><span class="stl_17 stl_08 stl_19" style="word-spacing:-0.0041em;">dysphagia of</span><span class="stl_17 stl_08 stl_14" style="word-spacing:0.1527em;"> </span><span class="stl_17 stl_08 stl_09" style="word-spacing:-0.0028em;">solid foods for three years </span></div>
</div>
</div>
</div>
The expected result is
<div class="stl_ stl_02">
<div class="stl_view">
<div class="stl_05 stl_06">
<div class="stl_01" style="left:18.0477em;top:1.7673em;"><span class="stl_15 stl_08 stl_16" style="word-spacing:0.1552em;">Chief Complaint  </span></div>
<div class="stl_01" style="left:1.6em;top:17.4546em;"><span class="stl_17 stl_08 stl_18" style="word-spacing:0.0066em;">This is a 37 y.o. WM who presents with </span></div>
<div class="stl_01" style="left:1.6em;top:21.0546em;"><span class="stl_17 stl_08 stl_19" style="word-spacing:-0.0041em;">dysphagia of</span><span class="stl_17 stl_08 stl_14" style="word-spacing:0.1527em;"> </span><span class="stl_17 stl_08 stl_09" style="word-spacing:-0.0028em;">solid foods for three years </span></div>
</div>
</div>
</div>
I tried this regex
let anchorString = anchorText.replace(/<div id="anchorWrap">\s*(.*?)\s*<\/div>/gi, "");
But was not able to remove that div. Please help me to achieve this.
Thanks in advance.