/// <summary>
/// 过滤掉html标签
/// </summary>
/// <param name="Htmlstring"></param>
/// <returns></returns>
public static string RemoveHTML(string htmlstring)
{
//删除脚本
htmlstring = Regex.Replace(htmlstring, @"<script[^>]*?>.*?</script>", "", 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 = htmlstring.Replace("<", "");
htmlstring = htmlstring.Replace(">", "");
htmlstring = htmlstring.Replace("\r\n", "");
htmlstring = HttpContext.Current.Server.HtmlEncode(htmlstring).Trim();
return htmlstring;
}

最新文章

  1. DDNS动态更新
  2. Eclipse里面的一些常规设置
  3. 64-who 简明笔记
  4. JavaScript 在不刷新或跳转页面的情况下改变当前浏览器地址栏上的网址
  5. [Leetcode][JAVA] Word Ladder
  6. [ACM_暴力] ZOJ 3710 [Friends 共同认识 最终认识 暴力]
  7. VS2008 调试记录
  8. HW4.17
  9. 重启iis线程池和iis站点
  10. 【MyBatis学习笔记】
  11. Android日志系统Logcat源代码简要分析
  12. git 使用详情
  13. Python之面向对象四
  14. mxGraph进阶(一)mxGraph教程-开发入门指南
  15. 『战略游戏 最大利润 树形DP』
  16. 面试中遇到的原生js题总结
  17. Python3.x - 字符串
  18. JDK1.7 高并发下的HashMap
  19. 【逆向工具】使用x64dbg+spy去除WinRAR5.40(64位)广告弹框
  20. 常用vimrc记录

热门文章

  1. Codeforces 712E Memory and Casinos
  2. [BZOJ 3564] [SHOI2014] 信号增幅仪 【最小圆覆盖】
  3. 大数据计算新贵Spark在腾讯雅虎优酷成功应用解析
  4. MySQL的if,case语句
  5. ConcurrentHashMap的get、put、size
  6. dpkg error
  7. bzoj3437
  8. OA请假流程 -- 编码
  9. POI做题记录:第二届POI
  10. 在Xcode中使用Clang Format