I am trying to remove blank paragraphs generated by TinyMCE. I want to use a RegEx because the set of HTML tags is finite in my universe but I am not sure how to go about it.
For this purpose my definition of blank is anything that does not have text. Here are some blank tag paragraphs I am getting from TinyMCE:
<p><strong><br></strong></p>
<p><br></p>
<p> </p>
<p></p>
Basically if no text is going to show up inside the paragraph tags, I want to remove it.. any ideas?
Give the Html Agility Pack a try, it'll parse your HTML fragment into a DOM which can be traversed to strip any <p> tags that meet your criteria. This'll be much easier and more robust that using a regex.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With