Context. I try to eliminate the tildes (spelling accents) and tildes, to compare 2 words. I did the function:
let sinDiacriticos = (function(){
let de = 'ÁÃÀÄÂÉËÈÊÍÏÌÎÓÖÒÔÚÜÙÛÑÇáãàäâéëèêíïìîóöòôúüùûñç',
a = 'AAAAAEEEEIIIIOOOOUUUUNCaaaaaeeeeiiiioooouuuunc',
re = new RegExp('['+de+']' , 'ug');
return texto =>
texto.replace(
re,
match => a.charAt(de.indexOf(match))
);
})();
let prue = 'Épico año de mal agüero, sólo Óscar y Ángel ganarán ésta. -Ímpetú Úrsula. ¡Ñañdú corre rápido por ahí!';
console.log(sinDiacriticos(prue));
// -> Epico ano de mal aguero, solo Oscar y Angel ganaran esta. -Impetu Ursula. ¡Nandu corre rapido por ahi!
**Question 1.** Is there a direct way to replace **any [diacritic][1]** without the need to manually generate a replacement map? I am interested in covering the diacritical marks of any language.
Question 2. Bearing in mind that in Spanish la ñ
is a different letter from n
, can diacritics be eliminated except if it is a ñ
?
* Question asked by blonfu in comments