Update removeAccents.md
This commit is contained in:
@ -5,11 +5,11 @@ tags: string,beginner
|
|||||||
|
|
||||||
Removes accents from strings.
|
Removes accents from strings.
|
||||||
|
|
||||||
- Converts the string to a normalized Unicode format.
|
- Use `String.prototype.normalize()` to convert the string to a normalized Unicode format.
|
||||||
- The diacritical marks are represented by an Unicode range and are replaced by empty strings.
|
- Use `String.prototype.replace()` to replace diacritical marks in the given Unicode range by empty strings.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const removeAccents = string => string.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
|
const removeAccents = str => str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
Reference in New Issue
Block a user