|","",RegexOptions.IgnoreCase);str=Rege..." />
正则表达式过滤html标签对
正则表达式过滤html标签对
发布时间:2015-05-12 来源:查字典编辑
摘要:publicstringDealHtml(stringstr){//str=Regex.Replace(str,@"]*>|","",Reg...

  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教程学习
热门脚本HTML教程学习
网页设计子分类