let a = "<p>10.1″ 1920 x 1200 IPS Display; ″ RAM & e";
function htmlCode2Char(str) {
let reg = /&#.*?;/g;
return str.replace(reg, m => {
let _reg = /&#(.+?);/g;
let code = _reg.exec(m);
return code && String.fromCharCode(code[1]);
});
};
String.prototype.decodeHTML = function () {
var map = { "gt": ">" };
return this.replace(/&(#(?:x[0-9a-f]+|\d+)|[a-z]+);?/gi, function ($0, $1) {
if ($1[0] === "#") {
return String.fromCharCode($1[1].toLowerCase() === "x" ? parseInt($1.substr(2), 16) : parseInt($1.substr(1), 10));
} else {
return map.hasOwnProperty($1) ? map[$1] : $0;
}
});
};
let bb = htmlCode2Char(a)
let cc = a.decodeHTML()
console.log(bb)
console.log(cc)