Unescapes escaped HTML characters.
String.prototype.replace()
with a regexp that matches the characters that need to be unescaped.const unescapeHTML = str =>
str.replace(
/&|<|>|'|"/g,
tag =>
({
'&': '&',
'<': '<',
'>': '>',
''': "'",
'"': '"'
}[tag] || tag)
);
unescapeHTML('<a href="#">Me & you</a>');
// '<a href="#">Me & you</a>'
JavaScript, String
Escapes a string for use in HTML.
JavaScript, String
Converts an hsl()
color string to an object with the values of each color.
JavaScript, String
Converts an rgb()
color string to an object with the values of each color.