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;
}
转载自:http://www.cnblogs.com/youring2/archive/2013/04/03/2997826.html
posted @ 2014-12-22 11:08  DESTLIVE  阅读(388)  评论(0编辑  收藏  举报