去除html标记和替换script标记
2020-12-13 02:34
标签:style class code ext color c 1: ///
2: /// 去除HTML标记
3: ///
4: /// 包括HTML的源码
5: ///
6: public static string RemoveHTML(string Htmlstring)
7: {
8: if (string.IsNullOrEmpty(Htmlstring))
9: {
10: return string.Empty;
11: }
12: //删除脚本
13: Htmlstring = Regex.Replace(Htmlstring, @"", "", RegexOptions.IgnoreCase);
14:
15: //删除HTML
16: Htmlstring = Regex.Replace(Htmlstring, @"]*)>", "", RegexOptions.IgnoreCase);
17: Htmlstring = Regex.Replace(Htmlstring, @"([\r\n])[\s]+", "", RegexOptions.IgnoreCase);
18: Htmlstring = Regex.Replace(Htmlstring, @"-->", "", RegexOptions.IgnoreCase);
19: Htmlstring = Regex.Replace(Htmlstring, @"
上一篇:WINFORM 打开PDF