去除网站中HTML标签的正则表达式
2010-05-24 16:44
627 查看
string str = a.ToString();
str = Regex.Replace(str, @"</?span[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[^>]*;", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?marquee[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?object[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?param[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?embed[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?table[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @" ","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?tr[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?th[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?p[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?a[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?img[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?tbody[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?li[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?span[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?div[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?th[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?td[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?script[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"(javascript|jscript|vbscript|vbs):", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"on(mouse|exit|error|click|key)", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<//?xml[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<//?[a-z]+:[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?font[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?b[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?u[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?i[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?strong[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?span[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"[^>]*;", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?marquee[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?object[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?param[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?embed[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?table[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @" ","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?tr[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?th[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?p[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?a[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?img[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?tbody[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?li[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?span[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?div[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?th[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?td[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?script[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"(javascript|jscript|vbscript|vbs):", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"on(mouse|exit|error|click|key)", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<//?xml[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"<//?[a-z]+:[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?font[^>]*>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?b[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?u[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?i[^>]*>","",RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"</?strong[^>]*>","",RegexOptions.IgnoreCase);
相关文章推荐
- 正则表达式,去除所有HTML标签
- 正则表达式,去除所有HTML标签
- python自带re模块正则表达式去除html标签
- Python通过正则表达式获取,去除(过滤)或者替换HTML标签的几种方法(本文由169it.com搜集整理)
- java/android 正则表达式去除所有HTML标签
- java正则表达式去除html标签
- 正则表达式去除html标签
- js过滤(去除)富文本编辑器中的html标签和换行回车等标记的正则表达式
- java正则表达式去除html标签
- 正则表达式去除数据带HTML标签方法
- 利用正则表达式实现去除所有HTML标签代码
- java正则表达式去除html标签
- Java中正则表达式去除html标签
- 正则表达式去除html标签
- 【转】java使用正则表达式去除字符串的html标签
- 笔记:JS利用正则表达式实现去除Html标签方法
- java正则表达式去除html标签
- [转]正则表达式,去除所有HTML标签
- Java去除掉HTML里面所有标签的两种方法——开源jar包和自己写正则表达式
- JS过滤(去除)富文本编辑器中的HTML标签和换行回车等标记的正则表达式