zoukankan      html  css  js  c++  java
  • c# 去除文本的html标签

     1 public static string ContentReplace(string input)
     2         {
     3             input = Regex.Replace(input, @"<(.[^>]*)>", "", RegexOptions.IgnoreCase);
     4             input = Regex.Replace(input, @"([
    ])[s]+", "", RegexOptions.IgnoreCase);
     5             input = Regex.Replace(input, @"-->", "", RegexOptions.IgnoreCase);
     6             input = Regex.Replace(input, @"<!--.*", "", RegexOptions.IgnoreCase);
     7 
     8             input = Regex.Replace(input, @"&(quot|#34);", """, RegexOptions.IgnoreCase);
     9             input = Regex.Replace(input, @"&(amp|#38);", "&", RegexOptions.IgnoreCase);
    10             input = Regex.Replace(input, @"&(lt|#60);", "<", RegexOptions.IgnoreCase);
    11             input = Regex.Replace(input, @"&(gt|#62);", ">", RegexOptions.IgnoreCase);
    12             input = Regex.Replace(input, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
    13             input = Regex.Replace(input, @"&(iexcl|#161);", "xa1", RegexOptions.IgnoreCase);
    14             input = Regex.Replace(input, @"&(cent|#162);", "xa2", RegexOptions.IgnoreCase);
    15             input = Regex.Replace(input, @"&(pound|#163);", "xa3", RegexOptions.IgnoreCase);
    16             input = Regex.Replace(input, @"&(copy|#169);", "xa9", RegexOptions.IgnoreCase);
    17             input = Regex.Replace(input, @"&#(d+);", "", RegexOptions.IgnoreCase);
    18 
    19             input.Replace("<", "");
    20             input.Replace(">", "");
    21             input.Replace("
    ", "");
    22             //去两端空格,中间多余空格
    23             input = Regex.Replace(input.Trim(), "\s+", " ");
    24             return input;
    25         }
  • 相关阅读:
    pyqt动画的使用
    pyqt 自定义信号
    设计工具- QtDesigner
    样式控制-QSS 样式表
    布局管理之 QStackedLayout (堆 布局)
    布局管理之 QGridLayout (网格布局)
    布局管理之 QFormLayout (表单布局)
    看代码中
    公司同事好坑
    我要多开梦幻手游PC端(梦幻手游PC端多开的简单分析及实现办法)
  • 原文地址:https://www.cnblogs.com/ghelement/p/4511499.html
Copyright © 2011-2022 走看看