我处理的是将标签外的空格替换成 替换特殊字符或内容修改一下即可
function removeNotHtmlBlank(str){
var str = ">" + str + "<";
var repStr=str.replace(/>[^<]*[^<]*</g, function(word){
return word.replace(/\s/g," ");
}
);
repStr = repStr.substring(1,repStr.length-1);
return repStr;
}