I've a string as "1,23,45,448.00"
and I want to replace all commas by decimal point and all decimal points by comma.
My required output is "1.23.45.448,00"
I've tried to replace ,
by .
as follow:
var mystring = "1,23,45,448.00"
alert(mystring.replace(/,/g , "."));
But, after that, if I try to replace .
by ,
it also replaces the first replaced .
by ,
resulting in giving the output as "1,23,45,448,00"
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…