Skip to content

Instantly share code, notes, and snippets.

@dotenorio
Last active April 20, 2017 13:11
Show Gist options
  • Save dotenorio/f424cea548b11ebb7c645e3a5306ae92 to your computer and use it in GitHub Desktop.
Save dotenorio/f424cea548b11ebb7c645e3a5306ae92 to your computer and use it in GitHub Desktop.
function removeAcentos (string) {
non_asciis = {
'a': '[àáâãäåª]',
'A': '[ÀÁÂÃÄÅ]',
'ae': 'æ',
'c': 'ç',
'C': 'Ç',
'e': '[èéêë]',
'E': '[ÈÉÊË]',
'i': '[ìíîï]',
'I': '[ÌÍÎÏ]',
'n': 'ñ',
'o': '[òóôõöº]',
'O': '[ÒÓÔÕÖ]',
'oe': 'œ',
'u': '[ùúûűü]',
'U': '[ÙÚÛŰÜ]',
'y': '[ýÿ]',
'Y': '[ÝŸ]'
};
for (i in non_asciis) { string = string.replace(new RegExp(non_asciis[i], 'g'), i); }
return string;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment