Reputation: 7872
In my application I use the javascript replace method with following regex:
replace(/\€/g,'$')
This code find € character and change it to $. But now I want to this code replace € and £ to $ character. How can I do that?
Upvotes: 0
Views: 76
Reputation: 70742
You can use a character class to define one of several characters, as well they dont need to be escaped.
'€ and £'.replace(/[£€]/g, '$'); //=> '$ and $'
Upvotes: 1
Reputation: 945
use this replace(/[\€\£]/g,'$')
You can mention 2 or more characters in square brackets to match them individually.
Upvotes: 1
Reputation: 664
Use the OR operator to combine the pound and euro symbols (of which you do not need to escape). The resulting regex would be:
/€|£/g
Upvotes: 1