zoukankan      html  css  js  c++  java
  • 去除html标签 正则表达式

     /// <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;
                }
            }

  • 相关阅读:
    图的深度遍历
    判断森林中有多少棵树
    基于邻接矩阵的广度优先搜索
    第三届程序设计知识竞赛网络赛
    大数相乘
    a+b=x,ab=y
    poj3278
    不敢死队
    单链表中重复元素删除
    poj2506
  • 原文地址:https://www.cnblogs.com/huhaihua/p/3656751.html
Copyright © 2011-2022 走看看