como usar o unescapeHTML no javascript es6
January 04, 2020
Unescapes escaped HTML characters.
Use String.prototype.replace()
with a regex that matches the characters that need to be unescaped, using a callback function to replace each escaped character instance with its associated unescaped character using a dictionary (object).
const unescapeHTML = str =>
str.replace(
/&|<|>|'|"/g,
tag =>
({
'&': '&',
'<': '<',
'>': '>',
''': "'",
'"': '"'
}[tag] || tag)
);
unescapeHTML('<a href="#">Me & you</a>'); // '<a href="#">Me & you</a>'