JavaScript Replace Method
CInglezDec 14 2009 — edited Dec 14 2009Hello all.
I am trying to use the replace javascript method to format a number, but with no success.
If the string is '123.567.789'
and I use x = x.replace(".", "$");
I get: '123$456.789'.
I mean, only the first occurence is replaced.
Browsing the internet, I saw people using
x = x.replace(/STRING/g, "NEW STRING");
The funny thing is: it works with most characters, but not with single dots, like "."
If I use x = x.replace(/./g, "$");
I get '$$$$$$$$$$$'.
All the characeters are replaced, not just the dot. How can I replace all ".", "/", "-" characters?
Thanks in advance.
Carlos Inglez