views:

25

answers:

2

Hi, I have this string:

Tue,Sep,21,15:48:1,CEST,2010

I would replace the "," with a space.

I have tried:

string=string.replace("/,/g"," ");

and the result is:

Tue,Sep,21,15:48:1,CEST,2010

I have tried:

string=string.replace(","," ");

and the result is:

Tue Sep,21,15:48:1,CEST,2010

How can I replace all the "," with " "?

Thanks.

+4  A: 

Remove the quotes around your regular expression and it will work:

string=string.replace(/,/g," ");
Chris Pebble
Thank you so much.
michele
+2  A: 

"/,/g" is a string, not a regular expression

/,/g is a regular expression.

string=string.replace(/,/g," ");
epascarello
Thank you so much.
michele