去掉html标签
作者:互联网
// 去掉html标签
function delHtmlTag(str){
return str ? str.replace(/<[^>]+>/g,"") : '';//去掉所有的html标记
}
/**
* 字符串是否含有html标签的检测
* @param htmlStr
*/
function checkHtml(htmlStr) {
var reg = /<[^>]+>/g;
return reg.test(htmlStr);
}
/**
* 将富文本转义的html代码 反转义
* @param str
*/
function htmlDecodeByRegExp (str){
var s = "";
if(str.length == 0) return "";
s = str.replace(/&/g,"&");
s = s.replace(/</g,"<");
s = s.replace(/>/g,">");
s = s.replace(/ /g," ");
s = s.replace(/'/g,"\'");
s = s.replace(/"/g,"\"");
return s;
}
标签:function,return,标签,replace,html,str,htmlStr,去掉 来源: https://blog.csdn.net/qq_30607437/article/details/120087854