文本编辑器html代码<变成& lt;解决

<script type="text/javascript">
var HtmlUtil = {
        /*1.用正则表达式实现html转码*/
        htmlEncodeByRegExp:function (str){  
             var s = "";
             if(str.length == 0) return "";
             s = str.replace(/&/g,"&amp;");
             s = s.replace(/</g,"&lt;");
             s = s.replace(/>/g,"&gt;");
             s = s.replace(/ /g,"&nbsp;");
             s = s.replace(/\'/g,"&#39;");
             s = s.replace(/\"/g,"&quot;");
             return s;  
       },
       /*2.用正则表达式实现html解码*/
       htmlDecodeByRegExp:function (str){  
             var s = "";
             if(str.length == 0) return "";
             s = str.replace(/&amp;/g,"&");
             s = s.replace(/&lt;/g,"<");
             s = s.replace(/&gt;/g,">");
             s = s.replace(/&nbsp;/g," ");
             s = s.replace(/&#39;/g,"\'");
             s = s.replace(/&quot;/g,"\"");
             return s;  
       }
    };
</script>

<script type="text/javascript">
    var html = "${tratext.text}";         
    //tratext 为参数传递
    var decodeHTML = HtmlUtil.htmlDecodeByRegExp(html);
    document.write(decodeHTML);
</script>
对不起,你提供的引用内容无法解读。请提供清晰的引用内容,以便我能够回答你的问题。谢谢。&lt;span class="em">1&lt;/span>&lt;span class="em">2&lt;/span>&lt;span class="em">3&lt;/span> #### 引用[.reference_title] - *1* [ &lt;msup> &lt;mi>γ&lt;/ mi> &lt;mo> * &lt;/ mo> &lt;/ msup> &lt;msup> &lt;mi>γ&lt;/ mi> &lt;mo> * &lt;/ mo> &lt; / msup> &lt;mo>→&lt;/ ...](https://download.csdn.net/download/weixin_38708361/12257900)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ &lt;mrow> &lt;msup> &lt;mrow> &lt;mi> D &lt;/ mi> &lt;/ mrow> &lt;mrow> &lt;mn> 0 &lt;/ mn> &lt;/ mrow> &lt;/ msup> &lt; / mrow> &lt...](https://download.csdn.net/download/weixin_38733367/12261729)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [java字符串转义,把&lt;>转换成&lt;>等字符](https://blog.csdn.net/aijian3049/article/details/101144255)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值