/// <summary>
/// 将HTML去除
/// </summary>
/// <param name="Htmlstring"></param>
/// <returns></returns>
public static string DelHTML(string Htmlstring)
{
#region
//删除脚本
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//删除HTML //Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<A>.*</A>","");
//Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<[a-zA-Z]*=\.[a-zA-Z]*\?[a-zA-Z]+=\d&\w=%[a-zA-Z]*|[A-Z0-9]","");
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(quot|#34);", "“", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(amp|#38);", "&", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(lt|#60);", "<", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(gt|#62);", ">", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(nbsp|#160);", " ", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(iexcl|#161);", "\xa1", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(cent|#162);", "\xa2", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(pound|#163);", "\xa3", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(copy|#169);", "\xa9", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&#(\d+);", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"<(.[^>]*)>", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"-->", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"<!--.*", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring, @"&(quot|#34);", "\"", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring.Replace("<", "");
Htmlstring.Replace(">", "");
Htmlstring.Replace("\r\n", "");
//Htmlstring=HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
#endregion
return Htmlstring;
}

最新文章

  1. Android业务组件化之URL Scheme使用
  2. Linux常用命令[转]
  3. windows无法停用“Android Composite Interface”设备的解决方法
  4. 使用页面Tag判断某个值为空值时,不能使用logic:equal(无效),可以使用logic:notPresent
  5. 《Cocos2d-x实战 C++卷》上线了-源码-样章-感谢大家的支持
  6. linux查看硬件信息的命令(图文)
  7. Linux下通过shell脚本创建账户
  8. 22个CSS黑魔法
  9. springMVC下载文件前修改文件名字
  10. 页面加载loading动画
  11. 【P2303】Longge的问题
  12. [Web 前端] mobx教程(五)-Mobx常见问题及解决方案(1)Mobx使用严格模式
  13. Linux下配置yum
  14. Java架构师最关键三个思维转变方式,框架的合理运用
  15. js中获取当前url参数值的一个方法
  16. C# 批量生成邮箱地址代码
  17. Java监听器原理及实例
  18. C# 二维码生成——QRCode
  19. PHP----练习-----三级联动
  20. 接口测试框架开发(一):rest-Assured_接口返回数据验证

热门文章

  1. jquery checkbox checked 却不显示对勾
  2. Android Studio下jni应用
  3. 在linux环境下编译android so库
  4. H3C S5120清除console口密码
  5. Tensorflow学习笔记——安装和运行
  6. Git合并最近的commit
  7. Linux内核 设备树操作常用API
  8. 【JS加密库】SJCL :斯坦福大学JS加密库
  9. Ubuntu下配置使用mysql
  10. solus 系统 - 安装 mariadb