用到了正则,需要using    命名空间.   
    
   using    System.Text.RegularExpressions; 
public static string ClearHtml(string strHtml)
    {
        if (!string.IsNullOrEmpty(strHtml))
        {
            Regex r = null;
            Match m = null;
            r = new Regex(@"<\/?[^>]*>", RegexOptions.IgnoreCase);
            for (m = r.Match(strHtml); m.Success; m = m.NextMatch())
            {
                strHtml = strHtml.Replace(m.Groups[0].ToString(), "");
            }
        }
        return strHtml;
    } 
- 本文标题: ASP.NET 过滤所有html标签得到纯文本
- 文章分类:【.NET/Web】
- 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
- 上一篇:为示哀悼,网站全部变成黑白色网站的CSS方法
- 下一篇: 抓取 中国银行外汇牌价表显示