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

416 B

title, tags
title tags
removeAccents 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.
const removeAccents = string => string.normalize("NFD").replace(/[\u0300-\u036f]/g, "")
removeAccents('Antoine de Saint-Exupéry'); // 'Antoine de Saint-Exupery'