How can I replace() multiple characters at once?
I have an string like this:
var set = 'ñ This is a Test Ñ';
What I need to do is replace ñ
and Ñ
with n
. I tried:
开发者_运维技巧set.replace(/\u00F1/g, 'n');
but it only replaces the ñ
.
I think there is a cleaner way to write this, but this should work. The |
acts as an OR
in regex.
a = set.replace(/\u00F1|\u00D1/g, 'n');
精彩评论