1 个回答

参考demo:

let reg :RegExp= new RegExp('apple','g');
let str = 'an apple apple apple apple.';
let newStr = str.replace(reg, 'fruit');
console.log(newStr); //输出: an fruit fruit fruit fruit
this.message = newStr
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进