js replace 如何替换字符串中的最后一个匹配项
时间:2019-12-24 14:07:35
收藏:0
阅读:716
正则表达时,贪婪模式,.*会一直匹配到最后一个
// 验证 let str = "hello world"; let res = str.replace(/(.*)l/,‘$10‘); //$1 + 替换后的字符 console.log(res); // hello wor0d
原文:https://www.cnblogs.com/weixuechao/p/12091139.html
评论(0)