I wrote a function in JavaScript, that replaces accents in a string to certain characters.
function textToURL(str) {
str = str.replace(/á/gi,'a');
str = str.replace(/é/gi,'e');
str = str.replace(/í/gi,'i');
str = str.replace(/ó/gi,'o');
str = str.replace(/ö/gi,'o');
str = str.replace(/ő/gi,'o');
str = str.replace(/ú/gi,'u');
str = str.replace(/ü/gi,'u');
str = str.replace(/ű/gi,'u');
str = str.replace(/ /gi,'-');
return str;
}
I'm sure there's a more clean and more simple way to write this code with arrays, or Regex, but how?
Thanks in advance.