Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaScript Replace Method

CInglezDec 14 2009 — edited Dec 14 2009
Hello 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2010
Added on Dec 14 2009
3 comments
763 views