javascript替换replaceALL正斜杠 反斜杠的方法
replaceALL正斜杠 反斜杠代码
var toPath="/a/b";
toPath = toPath.replace(///g,"_");
结果:_a_b
1》要想定义字符串abc需要这样写var str = "a\b\c";
2》alert(str.replace(/\/g,"/"));将abc 修改为a/b/c
var str = "a\b\c";
alert(str);
alert(str.replace(/\/g,"/"));
js将字符串中所有反斜杠替换成正斜杠/
区分正斜杠与反斜杠:
正斜杠:http://。http紧跟着的斜杠,离手输入最近的斜杠,shift中间斜杠。45度角斜杠。正斜杠不需要转义
反斜杠:回车与空格之间。程序表示时需要转义成\。
str.replace(/\/,/);