正则表达时,贪婪模式,.*会一直匹配到最后一个

// 验证
let str = "hello world";
let res = str.replace(/(.*)l/,'$10');   //$1 + 替换后的字符
console.log(res); // hello wor0d

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-20
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案