c#过滤html标签

public string HtmlFilter(string html)
    {
        //设置要删除的标记
        string[] lable = { "font""span""strong"" ""div""br" ," "};
        foreach (string lb in lable)
        {
            string reg = String.Format(@"</?{0}[^>]*?>", lb);
            //html = Regex.Replace(html, " ", "", RegexOptions.IgnoreCase);         
            html = Regex.Replace(html, reg, "", RegexOptions.IgnoreCase);
        }
        return html;         
        
    }

 

//lable里填写不需要的标签即可。

 

posted @ 2015-11-13 16:14  mali0932  阅读(145)  评论(0编辑  收藏  举报