Alizhou-Blog Alizhou-Blog

周黎的个人博客

目录
C#去除HTML标签
/  

C#去除HTML标签

public static string ReplaceHtmlTag(string html, int length = 0)
{
    string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
    strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
    if (length > 0  && strText.Length > length)
        return strText.Substring(0, length);
    return strText;
}

标题:C#去除HTML标签
作者:小周黎
地址:https://zhouli.info/articles/2020/04/01/1585717468240.html