除了字符串中的两个标签之外,如何删除所有html标签? [英] How to remove all html tags in except two tags in string?
本文介绍了除了字符串中的两个标签之外,如何删除所有html标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
示例:
Example:
<span style="font-weight: bold; font-size: 8pt">
<pre style="font-family: verdana">
<b>The Output Y(s) of the fig. is:
<br /><br />
<img src="http://192.168.5.151/UADP4.0/ItemAuthoring/QuestionBank/Resources/94954.jpeg" />
</b>
</pre>
</span>
这里的img和粗体标签应该保留,必须删除所有标签。请不要只考虑这个标签,哪些标签都是未知的.....请把它作为通用
Here img and bold tag should retain, all tags must removed. please don't consider only this tag, which tags are all using is unknown..... please make it as generic
<img></img>
<b></b>
和结果如:
and result like:
<b>The Output Y(s) of the fig. is:
<img src="http://192.168.5.151/UADP4.0/ItemAuthoring/QuestionBank/Resources/94954.jpeg" />
</b>
提前致谢
推荐答案
我建议使用Regex进行匹配和删除。 请参见 this [ ^ ] SO帖子解决了这个问题。
/ ravi
I recommend using Regex to do the match and removal. See this[^] SO post that solves this problem.
/ravi
这篇关于除了字符串中的两个标签之外,如何删除所有html标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文