首页 > 技术文章 > 正则替换所有的 ‘ / ’

mary-123 2019-10-29 15:13 原文

用正则表达式
var a="a/b/c/d";
console.log(a.replace(/\//g,'-'));

结果:a-b-c-d

推荐阅读