function NCRtoStr(inStr){ return inStr.replace(/&#(x[a-f0-9]{1,4}|[0-9]{1,5});/gi, function(str){ return str.match(/x/) ? String.fromCharCode(parseInt("0x" + str.match(/[a-f0-9]+/i))) : n = parseInt(str.match(/[0-9]+/i)) , n < 0x10000 ? String.fromCharCode(n) : str; }); }