如下代码段只能替换第一个逗号
var mystring = "this,is,a,test"
mystring.replace(",","newchar")
要替换所有逗号,需要使用如下代码:
var mystring = "this,is,a,test"
mystring.replace(/,/g, "newchar");
如下代码段只能替换第一个逗号
var mystring = "this,is,a,test"
mystring.replace(",","newchar")
要替换所有逗号,需要使用如下代码:
var mystring = "this,is,a,test"
mystring.replace(/,/g, "newchar");