Files
30-seconds-of-code/snippets/removeAccents.md
2020-10-04 10:40:01 -03:00

18 lines
416 B
Markdown

---
title: removeAccents
tags: string,beginner
---
Removes accents from strings.
- Converts the string to a normalized Unicode format.
- The diacritical marks are represented by an Unicode range and are replaced by empty strings.
```js
const removeAccents = string => string.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
```
```js
removeAccents('Antoine de Saint-Exupéry'); // 'Antoine de Saint-Exupery'
```