正则使用及去除html注释(富文本编辑器生成的兼容性脚本)

<script type="text/javascript">
String.prototype.trim = function () {//删除左右两端的空格
return this.replace(/(^\s*)|(\s*$)/g, "");
}
window.onload = function () {
var ohtml = document.getElementById("selfhtml");
var html = ohtml.innerHTML;
html = html.replace(/&lt;!--[\s\S]*?--&gt;/ig, ''); //去除html注释
html = html.replace(/>\s+([^\s<]*)\s+</ig, '>$1<').trim(); //去除html标签间的多余空白
ohtml.innerHTML = html;
};
</script>
--******************************************************************************************************************

 

---================================================================================================================
//whs_outdtl_ctgbth_positionid = "~~99G06/E!99G06/E!99G06/E!99G06-E!99G06-E!";
//whs_outdtl_ctgbth_positionid = whs_outdtl_ctgbth_positionid.replace(/[\/,-]/ig, "");
//alert(whs_outdtl_ctgbth_positionid);
//LXH_IsLingHuo_LStr_CtgBth = "~~99G06/E!99G06/E!99G06/E!99G06-E!99G06-E!";
//whs_outdtl_ctgbth_positionid = "~~99G06-E!";
//whs_outdtl_ctgbth_positionid = "99G06/E";

whs_outdtl_ctgbth_positionid = whs_outdtl_ctgbth_positionid.replace(/[\/,-]/ig, "");
whs_outdtl_ctgbth_positionid = whs_outdtl_ctgbth_positionid+"!"
LXH_IsLingHuo_LStr_CtgBth = LXH_IsLingHuo_LStr_CtgBth.replace(/[\/,-]/ig, "");
var regExp = new RegExp(whs_outdtl_ctgbth_positionid, 'ig');
LXH_IsLingHuo_LStr_CtgBth = LXH_IsLingHuo_LStr_CtgBth.replace(regExp, "");
$$LXH_IsLingHuo_LStr_CtgBth.val(LXH_IsLingHuo_LStr_CtgBth);

if (LXH_IsLingHuo_LStr_CtgBth === "~~") {
$$hidIsLingHuo.val('n');
}
---================================================================================================================

posted @ 2017-07-26 17:30  haikuang  阅读(449)  评论(0)    收藏  举报