人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

提取HTML代碼中文字的C#函數

提取HTML代碼中文字的C#函數

更新時間:2022-08-06 文章作者:未知 信息來源:網絡 閱讀次數:

/// <summary>
  /// 去除HTML標記
  /// </summary>
  /// <param name="strHtml">包括HTML的源碼 </param>
  /// <returns>已經去除后的文字</returns>
  public static string StripHTML(string strHtml)
  {
   string [] aryReg ={
          @"<script[^>]*?>.*?</script>",

          @"<(\/\s*)?!?((\w+:)?\w+)(\w+(\s*=?\s*(([""'])(\\[""'tbnr]|[^\7])*?\7|\w+)|.{0})|\s)*?(\/\s*)?>",
          @"([\r\n])[\s]+",
          @"&(quot|#34);",
          @"&(amp|#38);",
          @"&(lt|#60);",
          @"&(gt|#62);",
          @"&(nbsp|#160);",
          @"&(iexcl|#161);",
          @"&(cent|#162);",
          @"&(pound|#163);",
          @"&(copy|#169);",
          @"&#(\d+);",
          @"-->",
          @"<!--.*\n"
        
         };

   string [] aryRep = {
           "",
           "",
           "",
           "\"",
           "&",
           "<",
           ">",
           " ",
           "\xa1",//chr(161),
           "\xa2",//chr(162),
           "\xa3",//chr(163),
           "\xa9",//chr(169),
           "",
           "\r\n",
           ""
          };

   string newReg =aryReg[0];
   string strOutput=strHtml;
   for(int i = 0;i<aryReg.Length;i++)
   {
    Regex regex = new Regex(aryReg[i],RegexOptions.IgnoreCase );
    strOutput = regex.Replace(strOutput,aryRep[i]);
   }

   strOutput.Replace("<","");
   strOutput.Replace(">","");
   strOutput.Replace("\r\n","");


   return strOutput;
  }

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 福鼎市| 称多县| 合山市| 都江堰市| 齐齐哈尔市| 新建县| 阿拉善左旗| 小金县| 卫辉市| 邓州市| 师宗县| 泗水县| 抚松县| 博乐市| 德江县| 义乌市| 密山市| 潼关县| 榆树市| 定日县| 阿尔山市| 黎平县| 阳曲县| 惠来县| 交口县| 化州市| 绥德县| 班戈县| 壶关县| 翁牛特旗| 嘉祥县| 阳原县| 宁波市| 曲阜市| 东方市| 普陀区| 聂拉木县| 诸城市| 神木县| 龙江县| 宜川县|