public string NoHTML(string Htmlstring)  //替换HTML标记
{
//删除脚本
Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase); 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 = Regex.Replace(Htmlstring, @"<img[^>]*>;", "", RegexOptions.IgnoreCase);
Htmlstring.Replace("<", "");
Htmlstring.Replace(">", "");
Htmlstring.Replace("\r\n", "");
Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
return Htmlstring;
}

最新文章

  1. Python 【第五章】:线程、进程和协程
  2. Python socket超时
  3. coreData数据操作
  4. python 延迟绑定
  5. jQuery基础(2)-- jQuery 选择器
  6. sql 时间查询 /sql中判断更新或者插入/查询一年所有双休日
  7. 一个基于和围绕Docker生态环境构建的早期项目列表
  8. 分页sql存储过程算法
  9. URAL 1097 Square Country 2 离散化
  10. git log
  11. linq中的contains条件
  12. 30个最常用css选择器解析
  13. C++中构造函数或析构函数定义为private
  14. Linux重启后raid5的名字发生变化
  15. sql server 性能调优之 死锁排查
  16. js 异步代码
  17. java利用poi解析excel文件
  18. Python简单介绍
  19. 机器学习进阶-图像特征harris-角点检测 1.cv2.cornerHarris(进行角点检测)
  20. .net连mysql数据库汇总

热门文章

  1. NX二次开发-UFUN创建固定的基准平面UF_MODL_create_fixed_dplane
  2. 其它课程中的python---4、Matplotlib最最最最简单使用
  3. ggplot2在一幅图上画两条曲线
  4. mysql数据库中的索引介绍与优化(转)
  5. Apache Shiro RememberMe 1.2.4 反序列化漏洞
  6. &lt;后端&gt;Flask框架
  7. 【2018ACM/ICPC网络赛】徐州赛区
  8. 006-Java的break和continue
  9. 一些CSS3新技术
  10. Windows7 打开word2003提示:向程序发送命令时出现错误 解决方案