每个人都希望每天都是开心的,不要因为一些琐事扰乱了心情还,闲暇的时间怎么打发,关注图老师可以让你学习更多的好东西,下面为大家推荐正则表达式过滤html标签对,赶紧看过来吧!
【 tulaoshi.com - Web开发 】
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);
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)//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", "");
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/webkaifa/)return str;
}
来源:http://www.tulaoshi.com/n/20160219/1608621.html
看过《正则表达式过滤html标签对》的人还看了以下文章 更多>>