-
-
Save diogenesjup/60ab41deea360c972efde88a010e51c3 to your computer and use it in GitHub Desktop.
Funcao marota para remover acentos de strings. Foi utilizado expressao regular em cima de caracteres representados na base hexadecimal.
This file contains 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
/** | |
* Remove acentos de caracteres | |
* @param {String} stringComAcento [string que contem os acentos] | |
* @return {String} [string sem acentos] | |
*/ | |
function removerAcentos( newStringComAcento ) { | |
var string = newStringComAcento; | |
var mapaAcentosHex = { | |
a : /[\xE0-\xE6]/g, | |
e : /[\xE8-\xEB]/g, | |
i : /[\xEC-\xEF]/g, | |
o : /[\xF2-\xF6]/g, | |
u : /[\xF9-\xFC]/g, | |
c : /\xE7/g, | |
n : /\xF1/g | |
}; | |
for ( var letra in mapaAcentosHex ) { | |
var expressaoRegular = mapaAcentosHex[letra]; | |
string = string.replace( expressaoRegular, letra ); | |
} | |
return string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment