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

Reading number is top 10 articles
警告!Ajax技术的安全问题不容忽视_.net资料_编程技术
C#中定义鼠标指针为指定的动画图标实例
.net读取扩展名为xml的资源文件_[Asp.Net教程]
ASP.NET中文显示之两种解决方法_[Asp.Net教程]
JS-AJAX入门实例:循环,函数,对象,对象属性_JavaScript技术_编程技术
两个小问题where 1=1 和 count(1) 与 count(-)_[SQL Server教程]
delphi单行编辑框组件(TEdit)使用实例
数据库的备份与还原_[SQL,Server教程]
动态网页技巧:PHP,MySQL,integration_php资料_编程技术
C#教程:微软事务服务器应用实例
Reading number is top 10 pictures
Summer is most suitable for young people to travel in China1
清纯性感的美眉1
The Soviet union swimsuit exposure in the 70 year3
来几张有特色的图片
9.3阅兵全景图5-地空反舰导弹梯队
The terra-cotta warriors3
机器人也有性生活吗?
每天进步一点点
So beauty, will let you spray blood1
含苞欲放的素颜美少女1
Download software ranking
Sora aoi's film--cangkong_Blue.Sky
虚拟机5.5.3版
Red cliff
Popkart Cracked versions Mobile phone games
金山office2007
linux初级教程
软件工程思想
Be there or be square
Kung.Fu.Panda.2
网页特效实例大全
aaa published in(发表于) 2013/12/6 10:26:54 Edit(编辑)
利用正则表达式去掉html代码_.net资料_编程技术

利用正则表达式去掉html代码_.net资料_编程技术

利用正则表达式去掉html代码_.net资料_编程技术-数科优化网







using System.Text.RegularExpressions;//需要引用




// 利用正则表达式去掉"<"和">"之间的内容
private string StripHT(string strHtml)
{
Regex regex=new Regex("<.+?>",RegexOptions.IgnoreCase);
string strOutput=regex.Replace(strHtml,"");
return strOutput;
}





//方法二(不知为什么此方法占用CPU100%)




public static string DropHTML(string strHtml)
{
string [] aryReg ={
@"]*?>.*?",
@"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""''])(\\[""''tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>",
@"([\r])[\s]+",
@"&(quot|#34);",
@"&(amp|#38);",
@"&(lt|#60);",
@"&(gt|#62);",
@"&(nbsp|#160);",
@"&(iexcl|#161);",
@"&(cent|#162);",
@"&(pound|#163);",
@"&(copy|#169);",
@"&#(\d+);",
@"-->",
@"

"
};




string [] aryRep = {
"",
"",
"",
"\"",
"&",
"<",
">",
" ",
"\xa1",//chr(161),
"\xa2",//chr(162),
"\xa3",//chr(163),
"\xa9",//chr(169),
"",
"\r",
""
};




string newReg =aryReg[0];
string strOutput=strHtml;
for(int i = 0;i {
Regex regex = new Regex(aryReg[i],RegexOptions.IgnoreCase );
strOutput = regex.Replace(strOutput,aryRep[i]);
}




strOutput.Replace("<","");
strOutput.Replace(">","");
strOutput.Replace("\r","");
return strOutput;

}



























添加到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.