Reputation: 345
I want to replace all the occurrences of accented characters À, Á, Â, Ã, Ä, Å with "A" using javascript replace ( For example, "ÀNÁPIÂLÃZÄ" would be rendered to "ANAPIALAZA"). I tried:
var re = /À||Á||À||Á||Â||Ã||Ä||Å/g;
name = name.replace(re,"A");
and
var re = /(ÀÁÂÃÄÅ)/g;
name = name.replace(re,"A");
I not sure how to express the desired rule in regex pattern. Thanks
Upvotes: 0
Views: 2084
Reputation: 59273
Use []
square brackets, like this:
/[ÀÁÀÁÂÃÄÅ]/g
The problem with your first ||
example, by the way, is that you should only use one |
in regexes.
Upvotes: 1
Reputation: 3572
Square [ ] brackets will solve your problem.
var re = /[ÀÁÂÃÄÅ]/g;
name = name.replace(re,"A");
Example: http://jsfiddle.net/y2a6x/
Upvotes: 1