开发者

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

开发者 https://www.devze.com 2023-04-12 01:54 出处:网络
I need to strip all html tags from a string except <sub></sub> & <sup></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&开发者_Python百科lt;/p> <span class="required">H<sub>2</sub>O</span>"

Output should be Hello world H<sub>2</sub>O


Rather than using regular expressions, you may find it easier to use something like Html Agility Pack which gives you a read/write DOM to play with.

0

精彩评论

暂无评论...
验证码 换一张
取 消