Mo. Mo. - 4 years ago 257
Javascript Question

Replace forward slash "/ " character in JavaScript string?

I have this string:

var someString = "23/03/2012";

and want to replace all the "/" with "-".

I tried to do this:

someString.replace(///g, "-");

But it seems you cant have a forward slash in there.


Answer Source

You need to escape your slash.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download