Jim Schwetz
asked on
Find and replace part of inner div
How do I find and replace to remove inside div child element, keeping everything (all <p>*</p>'s) . some times their is just on p element, and sometimes alot.
link to regex101
I just want to remove:
I think I need to create a group for one or many p elements (<p>.*</p>) then replace with $1? So I keep the p's? (This does not work)
Can you provide a link to a resource to help me with regex as I do a lot of replaces/removals.
It would look like this when done.
Thanks in advance. I am not good with regex.
link to regex101
<div class="expand_collapse section_box">
<h2>Animal </h2>
<div class="box_content">
<div class="expand_collapse section_box">
<h2>Agent Facing</h2>
<div class="box_content">
<p><a href="/Brochure.pdf" target="_blank">Animal<br>(bully breeds & bite history)</a></p>
</div>
</div>
<div class="expand_collapse section_box">
<h2>Consumer Facing</h2>
<div class="box_content">
<p>content</p>
</div>
</div>
</div>
</div>
<!-- Next Product -->
I just want to remove:
<div class="expand_collapse section_box">
<h2>Agent Facing</h2>
<div class="box_content">
and </div>
</div>
<div class="expand_collapse section_box">
<h2>Consumer Facing</h2>
<div class="box_content">
<p>content</p>
</div>
</div>
so keeping one or more of the 'P' elements inside the second div.box_content element.I think I need to create a group for one or many p elements (<p>.*</p>) then replace with $1? So I keep the p's? (This does not work)
Can you provide a link to a resource to help me with regex as I do a lot of replaces/removals.
It would look like this when done.
<div class="expand_collapse section_box">
<h2>Animal </h2>
<div class="box_content">
<p><a href="/Brochure.pdf" target="_blank">Animal<br>(bully breeds & bite history)</a></p>
</div>
</div>
<!-- Next Product -->
Thanks in advance. I am not good with regex.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for the help rpremuz, This is a skill I need to get better at.
Thanks,
Jim
Thanks,
Jim
ASKER