3
votes

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>&nbsp;</p>
<p></p>

Basically if no text is going to show up inside the paragraph tags, I want to remove it.. any ideas?

1

1 Answers

2
votes

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.