Unescaping HTML in a string by replacing:
< with <
> with >
" with "
' with '
& with &
-----------------------------------
function unEscape(htmlStr) {
htmlStr = htmlStr.replace(/</g , "<");
htmlStr = htmlStr.replace(/>/g , ">");
htmlStr = htmlStr.replace(/"/g , """);
htmlStr = htmlStr.replace(/'/g , "'");
htmlStr = htmlStr.replace(/&/g , "&");
return htmlStr;
}
let unEscapedStr =unEscape(`<script>alert('hi')</script>`);
console.log(unEscapedStr);