现在的位置: 首页 > 综合 > 正文

去除字符串中的html标记

2013年12月12日 ⁄ 综合 ⁄ 共 310字 ⁄ 字号 评论关闭
正则表达式匹配下html标记
 public static string DeleteHTMLElement(string html)
        {
            html = Regex.Replace(html, "<[^>]*>{1}", "", RegexOptions.IgnoreCase);
            html = html.Replace("\n", " ");
            html = html.Replace("\t", " ");
            html = html.Replace("\r", " ");
            html = html.Replace("&nbsp ", " ");
            html = html.Replace("&quot", " ");
            return Regex.Replace(html, " \\s{2,}", " ");
        }

 

抱歉!评论已关闭.