首页 > Web开发 > 详细

去除html标签 正则表达式

时间:2014-04-10 22:26:28      阅读:743      评论:0      收藏:0      [点我收藏+]

 /// <summary>
        /// 去除html标签
        /// </summary>
        public static string ClearHtmlTag(string strText)
        {
            try
            {
                string html = strText;
                html = Regex.Replace(html, @"<[^>]+/?>|</[^>]+>", "", RegexOptions.IgnoreCase);
                html = Regex.Replace(html, @"-->", "", RegexOptions.IgnoreCase);
                html = Regex.Replace(html, @"<!--.*", "", RegexOptions.IgnoreCase);
                html = Regex.Replace(html, @"&(nbsp|#160);", " ", RegexOptions.IgnoreCase);
                html = Regex.Replace(html, @"&#(\d+);", "", RegexOptions.IgnoreCase);

                return html;
            }
            catch
            {
                return strText;
            }
        }

去除html标签 正则表达式,布布扣,bubuko.com

去除html标签 正则表达式

原文:http://www.cnblogs.com/huhaihua/p/3656751.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!