Prepare repository for merge
This commit is contained in:
21
javascript/snippets/remove-accents.md
Normal file
21
javascript/snippets/remove-accents.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
title: Remove accents
|
||||
type: snippet
|
||||
tags: [string]
|
||||
cover: pink-flowers
|
||||
dateModified: 2020-10-22T20:24:04+03:00
|
||||
---
|
||||
|
||||
Removes accents from strings.
|
||||
|
||||
- Use `String.prototype.normalize()` to convert the string to a normalized Unicode format.
|
||||
- Use `String.prototype.replace()` to replace diacritical marks in the given Unicode range by empty strings.
|
||||
|
||||
```js
|
||||
const removeAccents = str =>
|
||||
str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||
```
|
||||
|
||||
```js
|
||||
removeAccents('Antoine de Saint-Exupéry'); // 'Antoine de Saint-Exupery'
|
||||
```
|
||||
Reference in New Issue
Block a user