zoukankan      html  css  js  c++  java
  • 去除Html标签

    解析html最主要的就是利用正则表达式解析w3c中的html标签

        public class HtmlHelper
        {
            public static string ReplaceHtmlTag(string html, int length = 0)
            {
                string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");//替换html标签
                strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");//替换&gt&lt等特殊标签
                if (length > 0 && strText.Length > length)
                    return strText.Substring(0, length);
                strText = strText.Replace("
    ", "").Replace(" ", "").Replace("	", "").Replace("
    ", "");//去除换行符、制表符、空格
                return strText;
            }
        }
    






  • 相关阅读:
    UVA 10604 Chemical Reaction
    UVA 10635 Prince and Princess
    UVA 607 Scheduling Lectures
    Create Maximo Report
    安裝及配置Maximo Report步驟
    check blocking
    數據據類型縮寫
    .net
    poj3522
    poj1286
  • 原文地址:https://www.cnblogs.com/cqxhl/p/12993309.html
Copyright © 2011-2022 走看看