Skip to content

Instantly share code, notes, and snippets.

@dmiro
Created October 22, 2015 14:44
Show Gist options
  • Select an option

  • Save dmiro/dadf9d6ecd9fbb6add5f to your computer and use it in GitHub Desktop.

Select an option

Save dmiro/dadf9d6ecd9fbb6add5f to your computer and use it in GitHub Desktop.
var normalizarTexto = function(texto){
var accents = {
'à':'a','á':'a','â':'a','ã':'a','ä':'a','å':'a','æ':'e','è':'e','é':'e','ê':'e','ë':'e','ì':'i',
'í':'i','î':'i','ò':'o','ó':'o','ô':'o','ö':'o','ù':'u','ú':'u','û':'u','ü':'u','ñ':'n'
};
texto = texto.toLowerCase();
texto = texto.replace(/[àáâãäåæèéêëìíîòóôöùúûüñ]/gi, function(m){return accents[m];});
texto = texto.replace(/\s/gi,"");
return texto;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment