简体   繁体   中英

Remove blank paragraph tags - TinyMCE

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM