Update unescapeHTML.md
This commit is contained in:
@ -5,7 +5,7 @@ Unescapes escaped HTML characters.
|
|||||||
Use `String.replace()` with a regex that matches the characters that need to be escaped, using a callback function to replace each escaped character instance with its associated unescaped character using a dictionary (object).
|
Use `String.replace()` with a regex that matches the characters that need to be escaped, using a callback function to replace each escaped character instance with its associated unescaped character using a dictionary (object).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const unescapeHTML = str => str.replace(/[&<>'"]/g, tag => ({
|
const unescapeHTML = str => str.replace(/&|<|>|'|"/g, tag => ({
|
||||||
'&': '&',
|
'&': '&',
|
||||||
'<': '<',
|
'<': '<',
|
||||||
'>': '>',
|
'>': '>',
|
||||||
|
|||||||
Reference in New Issue
Block a user