Node.js实现ReplaceAll方法

exports.replaceAll = function (find, replace, str) {
  var find = find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  return str.replace(new RegExp(find, 'g'), replace);
}

 

posted @ 2018-02-02 11:32  yudis  阅读(6338)  评论(0编辑  收藏  举报