Remove Unused (Empty) HTML Tags

c# html-agility-pack regex replace

Question

I'm looking way to clear/remove all HTML tags they have nothing...

For example:

<p></p><div> to make links</div><b> </b>
<a href="http://foo.com"></a><p> for linebreak add 2 spaces at end
</p><strong></strong><i></i>

To:

<div> to make links</div><p> for linebreak add 2 spaces at end</p>

//I'm sure it is not dublicate.

Popular Answer

<[^>]*>\s*<\/[^>]*>

Try this.This will remove empty tags.See demo.

http://regex101.com/r/hQ1rP0/26




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why