zoukankan      html  css  js  c++  java
  • js正则表达式替换HTML标签以及空格( )

    参考:范仁义

     js代码:

          function  filter(text) {
                var reg = /<[^<>]+>/g;//1、全局匹配g肯定忘记写,2、<>标签中不能包含标签实现过滤HTML标签
                text = text.replace(reg, '');//替换HTML标签
                text = text.replace(/&nbsp;/ig, '');//替换HTML空格
                return text;
            };

    在angularJS中使用过滤器过滤富文本数据

        app.filter('qxhtml', function () {
            return function (text) {
                var reg = /<[^<>]+>/g;
                text = text.replace(reg, '');
                text = text.replace(/&nbsp;/ig, '');
                if (text.length > 50) {
                    text = text.substring(0, 50) + "...";
                }
                return text;
            };
        });

    使用过滤器

    <div class="desc">
         {{y.Description| qxhtml}}
    </div>
  • 相关阅读:
    LOD
    优化
    Shader
    资源:创建 加载 存储 使用 ---- 热更新
    内存
    分辨率自适应
    基础知识 索引
    【转】七年IT经验的七个总结
    c#
    绘制原理
  • 原文地址:https://www.cnblogs.com/dawenyang/p/10775652.html
Copyright © 2011-2022 走看看