C# 去除Html标签

  • Post author:
  • Post category:其他


 public static string ReplaceHtmlTag(string html, int length = 0){
            string strText = Regex.Replace(html, "<[^>]+>", "");
            strText = Regex.Replace(strText, "&[^;]+;", "");

            if (length > 0 && strText.Length > length)
                return strText.Substring(0, length);

            return strText;
 } 



版权声明:本文为fy809178958原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。