const html = ``; function unpack(p, a, c, k) { const e = function (c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)); }; while (c--) { if (k[c]) { p = p.replace(new RegExp('\\\\b' + e(c) + '\\\\b', 'g'), k[c]); } } return p; } const match = html.match(/eval\(function\(p,a,c,k,e,d\).*?return p}\('(.*?)',(\d+),(\d+),'([^']+)'\.split\('\|'\)/); if (match) { const p = match[1]; const a = parseInt(match[2], 10); const c = parseInt(match[3], 10); const k = match[4].split('|'); const unpacked = unpack(p, a, c, k); console.log(unpacked); } else { console.log("No match"); }