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

Reading number is top 10 articles
利用继承来制作点击提交按钮后按钮变灰_[Asp.Net教程]
数据库索引应用(ms-sql)_mssql学习_编程技术
PHP入门:初学来看配置文件PHP.INI的中文注释_[PHP教程]
技巧,.NET如何访问MySQL数据库_.net资料_编程技术
解答:如何使用PHP开发高效的WEB系统_php资料_编程技术
C#中窗体继承的应用
ASP.Net基础学习,HTML控件,简单介绍_[Asp.Net教程]
PHP和MySQL基础教程(四)_[PHP教程]
Windows环境PHP打开显示空白页面_php资料_编程技术
为不同的浏览器载入不同CSS的二种方法_[Html教程]
Reading number is top 10 pictures
In the world the most mysterious 21 place landscape1
Beautiful Japanese beauty(漂亮的日本美女)
Terrorist smile the largest human history an explosion2
The hot big eye big breast beauty2
美丽的风景--让你目瞪口呆
The real super beauty1
Extremely rare TianShan Mountains snow lotus2
The money of more than 100 countries and regions15
8090后结婚的各种XX事
泳装名模阿尔贝特妮写真
Download software ranking
Tram sex maniac 2 (H) rar bag19
Boxer vs Yellow4
Unix video tutorial18
Sora aoi, the nurse, uniform ,nursing assistant
Unix video tutorial19
Prostitutes diary
Tram sex maniac 2 (H) rar bag13
Unix video tutorial5
VC++6.0简体中文版
Kung fu panda - the secret of the teacher
归海一刀 published in(发表于) 2014/1/30 1:32:03 Edit(编辑)
去除正文中的html标记,但是又想保留其中的<br>_[Asp.Net教程]

去除正文中的html标记,但是又想保留其中的<br>_[Asp.Net教程]

去除正文中的html标记,但是又想保留其中的
_[Asp.Net教程]

















先把
替换成别的,然后去掉html的tag,再把
替换回来。




///


/// 去除HTML标记 方法(1)
///

/// 包括HTML的源码




/// 已经去除后的文字
public static string NoHTML(string Htmlstring)
{
//删除脚本




Htmlstring = Regex.Replace(Htmlstring,@"]*?>.*?","",RegexOptions.IgnoreCase);
//删除HTML
Htmlstring = Regex.Replace(Htmlstring,@"<(.[^>]*)>","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"([\r\n])[\s]+","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"-->","",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"

","",RegexOptions.IgnoreCase);




Htmlstring = Regex.Replace(Htmlstring,@"&(quot|#34);","\"",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(amp|#38);","&",RegexOptions.IgnoreCase);




Htmlstring = Regex.Replace(Htmlstring,@"&(lt|#60);","<",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(gt|#62);",">",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(nbsp|#160);"," ",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(iexcl|#161);","\xa1",RegexOptions.IgnoreCase);




Htmlstring = Regex.Replace(Htmlstring,@"&(cent|#162);","\xa2",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(pound|#163);","\xa3",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring,@"&(copy|#169);","\xa9",RegexOptions.IgnoreCase);
Htmlstring = Regex.Replace(Htmlstring, @"&#(\d+);","",RegexOptions.IgnoreCase);
Htmlstring.Replace("<","");
Htmlstring.Replace(">","");
Htmlstring.Replace("\r\n","");
Htmlstring=HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
return Htmlstring;
}







///


/// 去除HTML标记 方法(2)
///




public static string ParseTags(string HTMLStr)
{
return System.Text.RegularExpressions.Regex.Replace(HTMLStr, "<[^>]*>", "");
}


































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