-
-
Save leandromarques/6061e9f0bb42c837154c to your computer and use it in GitHub Desktop.
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
/** | |
* Remove accent | |
* @param {String} newString [string with accents] | |
* @return {String} [string without accents] | |
*/ | |
function removeAccents( newString ) { | |
let string = newString; | |
let mapHex = { | |
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 ( let word in mapHex ) { | |
let regularExpression = mapHex[word]; | |
string = string.replace( regularExpression, word ); | |
} | |
return string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment