欢迎来到山村网

正则表达式过滤html标签对

2019-03-28 23:18:52浏览:80 来源:山村网   
核心摘要:public string DealHtml(string str){//str = Regex.Replace(str, @(img)[^]*|/(img), , RegexOptions.IgnoreCase);str = Regex.

public string DealHtml(string str)

{

//str = Regex.Replace(str, @"<(img)[^>]*>|</(img)>", "", RegexOptions.IgnoreCase);

str = Regex.Replace(str, @"<(table|tbody|tr|td|th)[^>]*>|</(table|tbody|tr|td|th)>", "", RegexOptions.IgnoreCase);

str = Regex.Replace(str, @"<(div|blockquote|fieldset|legend)[^>]*>|</(div|blockquote|fieldset|legend)>", "", RegexOptions.IgnoreCase);

//str = Regex.Replace(str, @"<(font|i|u|h[1-9]|s)[^>]*>|</(font|i|u|h[1-9]|s)>", "", RegexOptions.IgnoreCase);

//str = Regex.Replace(str, @"<(style|strong)[^>]*>|</(style|strong)>", "", RegexOptions.IgnoreCase);

//str = Regex.Replace(str, @"<a[^>]*>|</a>", "", RegexOptions.IgnoreCase);

//str = Regex.Replace(str, @"<(meta|iframe|frame|span|tbody|layer)[^>]*>|</(iframe|frame|meta|span|tbody|layer)>", "", RegexOptions.IgnoreCase);

str = Regex.Replace(str, @"<br[^>]*", "", RegexOptions.IgnoreCase);

str = str.Replace("<br>", "");

return str;

}

(责任编辑:豆豆)
下一篇:

HTML表格边框样式属性FRAME

上一篇:

弹出打印窗口的一个方法

  • 信息二维码

    手机看新闻

  • 分享到
打赏
免责声明
• 
本文仅代表作者个人观点,本站未对其内容进行核实,请读者仅做参考,如若文中涉及有违公德、触犯法律的内容,一经发现,立即删除,作者需自行承担相应责任。涉及到版权或其他问题,请及时联系我们 xfptx@outlook.com