简体   繁体   中英

Regular expression to strip all HTML tags except sub & sup tags

I need to strip all html tags from a string except <sub></sub> & <sup></sup> tags.

Suppose if a string is "<p>Hello world</p> <span class="required">H<sub>2</sub>O</span>"
Output should be Hello world H<sub>2</sub>O

您可能会发现使用Html Agility Pack更容易使用正则表达式,而不是使用正则表达式,它可以为您提供读/写DOM

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