Skip to content

Instantly share code, notes, and snippets.

@lgarciasbr
Created May 10, 2018 15:05
Show Gist options
  • Select an option

  • Save lgarciasbr/cb2d187d325da4912c886e06bc60dc3a to your computer and use it in GitHub Desktop.

Select an option

Save lgarciasbr/cb2d187d325da4912c886e06bc60dc3a to your computer and use it in GitHub Desktop.
Função em TypeScript que remove acentos.
removerAcentos(s) {
var map = { "â": "a", "Â": "A", "à": "a", "À": "A", "á": "a", "Á": "A", "ã": "a", "Ã": "A", "ê": "e", "Ê": "E", "è": "e", "È": "E", "é": "e", "É": "E", "î": "i", "Î": "I", "ì": "i", "Ì": "I", "í": "i", "Í": "I", "õ": "o", "Õ": "O", "ô": "o", "Ô": "O", "ò": "o", "Ò": "O", "ó": "o", "Ó": "O", "ü": "u", "Ü": "U", "û": "u", "Û": "U", "ú": "u", "Ú": "U", "ù": "u", "Ù": "U", "ç": "c", "Ç": "C" };
return s.replace(/[\W\[\] ]/g, function (a) { return map[a] || a }).toLowerCase()
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment