Reputation: 4145
I'm looking for a negative lookahead that don't allow an open tag inside a tag, I try
/(<(\w+)[^>]*>)((?!<\2).*?)(<\/\2>)/gs
/(<(\w+)[^>]*>)((?!<\2).*)(<\/\2>)/gs
alpha
<div>
alpha<div>
beta<div>
x < y divided by 4
</div>
</div>
</div>
<div>
<span style="font-size: 8pt;" disabled title="data">
<span>
infinite
</span>
<?= $record->id ?>
</span>
<div> equal </div>
</div>
<div> sum </div>
When x y and y > 0
<div style="font-size: 8pt;" >Summary</div>
Equation id <?= $equation->id ?>
In this exampled they're the once containing:
Upvotes: -4
Views: 57
Reputation: 79218
Here is a regex you may want to use:
.*?<(\w+)[^>]*>((?:(?!<\1>).)*?)<\/\1>|.*
Click on it for explanation and also to see how to use it.
Upvotes: -1