本题摘自于我 github 上的面试每日一题: github.com/shfshanyue/… ,并有大厂面经及内推信息 如果需要全量替换字符串,可以使用 String.prototype.replace(re, replacer) ,其中正则表达式需要开启 global flag const s = 'foo foo foo' s.replce(/foo/g, 'bar') 复制代码 那如题中,是否可以使用正则表达式来...
本题摘自于我 github 上的面试每日一题: github.com/shfshanyue/… ,并有大厂面经及内推信息 如果需要全量替换字符串,可以使用 String.prototype.replace(re, replacer) ,其中正则表达式需要开启 global flag const s = 'foo foo foo' s.replce(/foo/g, 'bar') 复制代码 那如题中,是否可以使用正则表达式来...