/// <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标签 正则表达式的更多相关文章

  1. java正则表达式去除html标签

    当我们用ckeditor或其他一些在线文本编辑器的时候 内容里会有很多的标签 如下片段: <p><img alt="" src="/img/upload ...

  2. Java中正则表达式去除html标签

    Java中正则表达式去除html的标签,主要目的更精确的显示内容,比如前一段时间在做类似于博客中发布文章功能,当编辑器中输入内容后会将样式标签也传入后台并且保存数据库,但是在显示摘要的时候,比如显示正 ...

  3. asp.net正则表达式去除a标签

    if (drr["allow_a"].ToString() == "False") { cont = dr["news_Content"]. ...

  4. oracle clob字段去除html标签

    通过正则表达式的方式去除html标签 select regexp_replace(content,'</?[^>]*>|nbsp;|&','') content from T ...

  5. 织梦/dedecms采集怎么去除a标签

    dedecms采集去除a标签代码 DedeCMS采集规则-过滤-替换-技巧2009-01-14 15:491.采集去除链接[Copy to clipboard]CODE:{dede:trim}]*)& ...

  6. PHP 去除HTML标签 HTML实体转字符 br转\n

    1.去除HTML标签 strip_tags(string,allow)//剥去字符串中的 HTML 标签,但允许使用 <img> 标签:$str =  strip_tags($str,&q ...

  7. WP开发笔记——去除 HTML 标签

    获取到一段HTML类型的信息,显示在WP的webbrowser控件中,如果不加处理的话,会显示出各种神烦的HTML标签. 这时,需要我们将这HTML类型的信息进行处理去除HTML标签后再显示出来,这里 ...

  8. JS、C# 去除html标签

    JS去除html标签 var str = "<span style="display:none;" mce_style="display:none;&qu ...

  9. 正则去除字符串中的html标签,但不去除<br>标签

    一.去除html标签 filterHTMLTag(msg) { var msg = msg.replace(/<\/?[^>]*>/g, ''); //去除HTML Tag msg ...

随机推荐

  1. sql server中的 SET NOCOUNT ON 的含义

    每次我们在使用查询分析器调试SQL语句的时候,通常会看到一些信息,提醒我们当前有多少个行受到了影响,这是些什么信息?在我们调用的时候这些信息有用吗?是否可以关闭呢? 答案是这些信息在我们的客户端的应用 ...

  2. Js 设置class,兼容ie,火狐的方式

    var trs = document.getElementsByTagName("tr"); trs[0].className="color2";  //设置c ...

  3. 51. Word Search

    Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be constr ...

  4. [PAT]求集合数据的均方差(15)

    #include "stdio.h" #include "malloc.h" #include "math.h" int *getinput ...

  5. (1)as_view() (2)在urls.py里面出现的pk是怎么回事 (3)RetrieveAPIView表示什么

    下面的代码都是我从github上下载的源码中摘取的django: https://github.com/django/django 下载命令: git clone https://github.com ...

  6. x265编译

    x265 HEVC Encoder Mission Statement Online documentation Mailing list x265-devel@videolan.org HOWTO  ...

  7. 关于Function.prototype.bind

    bind()方法会创建一个新函数,称为绑定函数.当调用这个绑定函数时,绑定函数会以创建它时传入bind()方法的第一个参数作为 this,传入 bind() 方法的第二个以及以后的参数加上绑定函数运行 ...

  8. Python Django之路由系统

    1.初识路由系统 路由系统是用户发请求到URL,然后URL根据路由系统重新指向到函数名的一个对应关系 2.创建project和app django-admin startproject mysite ...

  9. linux(debian)下邮件发送

    关键字: exim4  mutt  smtp 主要的事情就是配置exim4,按照网上的流程来.在这里总结一下: 需要修改的文件有三个:/etc/exim4/update-exim4.conf.conf ...

  10. 当前JS文件中加入其他js文件

    注意:在html文件导入a.js时,应该把script></script写在/body>后面,否则 document.write()方法有问题. 在载入页面后,浏览器输出流自动关闭: ...