unescape
Converts the HTML entities &
, <
, >
, "
, and '
in str
to their corresponding characters. It is the inverse of escape
.
Signature
typescript
function unescape(str: string): string;
Parameters
str
(string
): The string to unescape.
Returns
(string
): The unescaped string.
Examples
typescript
import { unescape } from 'es-toolkit/string';
unescape('This is a <div> element.'); // returns 'This is a <div> element.'
unescape('This is a "quote"'); // returns 'This is a "quote"'
unescape('This is a 'quote''); // returns 'This is a 'quote''
unescape('This is a & symbol'); // returns 'This is a & symbol'