Edgar Santos

Edgar Santos

  • NA
  • 14
  • 0

Need help on replace using regular expression

Apr 9 2008 6:51 AM
Hi.

I have the following string "aaaaaa££aaaaa£aaaaa££"
and i want to replace £ for € and ££ for £.
(the string may change, but the rules are the same)

i've tried doing the following :
stringvar.replace(/[£]/g,"\u20AC")).replace(/[££]/g,"£")

It's obvious that the first replace replaces all £ by €..so the second replace never happens.

I'm trying to find a regular expression that helps me on this case, like saying to the replace that if he find a £ isolated from other £ he can replace for €. If not replace with £.

Hope you can help.

Cheers.

Answers (3)