您好,我需要从一个字符串中删除所有的 | 符号。这是我目前正在做的:
var mystring = "this|is|a|test"
console.log(mystring.replace(/|/g , ","));
这给我这个结果:,t,h,i,s,|,i,s,|,a,|,t,e,s,t, 这不是我想要的。为什么它不起作用?
当我尝试以下内容时,逗号可以正常工作。
var mystring = "this,is,a,test"
console.log(mystring.replace(/,/g , ":"));
这个让我得到 ----> 这个:是:一个:测试
为什么OR不能正常工作,我该如何修复?