新闻动态
新闻动态
- fckeditor在ie9中不支持$=document.getElementById解决办法
- ASP.NET Core EFCore 属性配置
- JavaScript中全局变量和局部变量的理解
- ThinkPHP6.0 入门3,连接配置数据、模型定义
- Nuxt 3中使用 definePageMeta 进行自定义配置
- 什么是DTO、VO、BO、PO、DO
- 矩阵号是什么意思
- C#设计模式(2)——简单工厂模式
- PHP 安装包的 Thread Safe和Non Thread Safe版本
- 我引用ConfigurationManager类为什么报错
联系我们
邮箱:
手机:15383239821
asp.net
去除HTML代码的类
作者:
发布时间:2013-04-11
点击:
- using System.Text.RegularExpressions; //包含正则表达式
- public static string NoHTML(string Htmlstring) //去除HTML标记
- {
- //删除脚本
- 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.Replace("<", "");
- Htmlstring.Replace(">", "");
- Htmlstring.Replace("/r/n", "");
- Htmlstring = HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
- return Htmlstring;
- }
- 上一篇:EVAL的使用方法
- 下一篇:.NET 中如何弹出新页面,而不出现阻止
新闻资讯
-
2019-12-05淘宝运营和天猫运营有什么区别?
-
2013-10-30request("id")与request.querystring("id")的区别
-
2011-04-09User.Identity.Name介绍1
-
2018-11-14微信营销思路 微信营销小套路
-
2023-09-22php类中的$this
-
2010-12-09如何早日走出google沙盒?
相关案例
