All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
最简单快速的Apache二级域名实现方法介绍_php资料_编程技术
ASP.NET,2.0中的页面输出缓存_[Asp.Net教程]
抓取网页中的链接_[Asp.Net教程]
js也可以有自定义事件,注入就是这么爽_.net资料_编程技术
细说数据库范式_mssql学习_编程技术
asp.net利用RAR实现文件压缩解压缩_[Asp.Net教程]
delphi设置代码模板
AJAX入门之使用for实现反射机制_[Asp.Net教程]
PHP,PEAR简介_php资料_编程技术
实现XmlHttp跨域访问用ASP.NET后台代码_[Asp.Net教程]
Reading number is top 10 pictures
Chinese paper-cut grilles art appreciation1
Discharge accidentally Actresses by the breast1
A man's favorite things3--ZhouWeiTong
到南昌西站了2
避免防盗门的猫眼变成钥匙眼
Fury xp desktop theme
Startling Russian girl blind date scene1
Summer is most suitable for young people to travel in China6
含苞欲放的素颜美少女3
Sora aoi calligraphy show
Download software ranking
Dance with duck(male prostitution)
VC++6.0简体中文版
The Bermuda triangle2
星际争霸1.08硬盘免安装版
C语言教程TXT
电车之狼R
少妇苏霞全本
Boxer's Top ten classic battle3
Boxer's Top ten classic battle7
The king of fighters 97(Mobile phone games-apk)
归海一刀 published in(发表于) 2014/1/30 1:01:10 Edit(编辑)
C#过滤所有HTML代码的函数_[Asp.Net教程]

C#过滤所有HTML代码的函数_[Asp.Net教程]

C#过滤所有HTML代码的函数_[Asp.Net教程]

























自己写的一段正则表达式,作用是删除 Page 里面Code 中的 HTML标签,这在做采集信息,消除其中的HTML很有用处,,欢迎大家收藏!

public string checkStr(string html)
{
System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[\s\S]*script *:", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" no[\s\S]*=", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"\]+\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"

", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"

", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
html = regex1.Replace(html, ""); //过滤标记
html = regex2.Replace(html, ""); //过滤href=javascript: () 属性
html = regex3.Replace(html, " _disibledevent="); //过滤其它控件的on...事件
html = regex4.Replace(html, ""); //过滤iframe
html = regex5.Replace(html, ""); //过滤frameset
html = regex6.Replace(html, ""); //过滤frameset
html = regex7.Replace(html, ""); //过滤frameset
html = regex8.Replace(html, ""); //过滤frameset
html = regex9.Replace(html, "");
html = html.Replace(" ", "");
html = html.Replace("", "");
html = html.Replace("", "");
return html;
}




来源:cnblogs
















































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.