-
去掉HTML标记和脚本正则
- using System.Text.RegularExpressions;
-
-
-
- public static string NoHTML(string Htmlstring)
- {
-
-
- Htmlstring = Regex.Replace(Htmlstring, @"<script[^>]*?>.*?</script>", "", RegexOptions.IgnoreCase);
-
- 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;
-
- }
-
相关阅读:
JS放在head和放在body中的区别
模板模式(Template Pattern)
原型模式
Linux下的头文件搜索路径
How to Change the Default Theme Appearance [editing with no theme]
版本控制
What is libacl.so.1 ?
交叉编译器 arm-linux-gnueabi 和 arm-linux-gnueabihf 的区别
mount --bind 的妙用
mount的bind选项
-
原文地址:https://www.cnblogs.com/wuhuisheng/p/1778789.html
Copyright © 2020-2023
润新知