close
用.replace("要被置換的字","要換成的字")
只會置換第一個
若要置換全部,必須用//g (golobal)
Ex:
var test = "B1 B2 S1/S2//End";
console.log(test);
=>結果: B1 B2 S1/S2//End
test = test.replace(" ", "-").replace("/", "-");
console.log(test);
=>結果: B1-B2 S1-S2//End
test = test.replace(/ /g, "-").replace(/\//g, "-");
console.log(test);
=>結果:B1-B2--S1-S2--End
全站熱搜