Is there any straightforward manner to make a character replacing in javascript of many chars in just one instruction with different replacement for each one, like it is possible in PHP?
I mean, something like:
replace('áéíóú', 'aeiou');
That replaces á with a, é with e, í with i, and so on...
Thanks a lot in advance,
Use regex with the global flag:
var map = {
"á": "a",
"é": "e",
"í": "i",
"ó": "o",
"ú": "u"
};
"áéíóú".replace(/[áéíóú]/g, function(m){
return map[m];
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With