Created
May 10, 2018 15:05
-
-
Save lgarciasbr/cb2d187d325da4912c886e06bc60dc3a to your computer and use it in GitHub Desktop.
Função em TypeScript que remove acentos.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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