let str = "hello world";
let res = str.replace(/(.*)l/,'1 + 替换后的字符
console.log(res); // hello wor0d
如果是一个变量,需要这样写:
'yyy.csv.pp.csv.csv'.replace(RegExp('(.*)' + this.profile.findTypeItem(info.Type).ext),'$1')
这样,就会将最后一个.csv替换为空白的
let str = "hello world";
let res = str.replace(/(.*)l/,'1 + 替换后的字符
console.log(res); // hello wor0d
如果是一个变量,需要这样写:
'yyy.csv.pp.csv.csv'.replace(RegExp('(.*)' + this.profile.findTypeItem(info.Type).ext),'$1')
这样,就会将最后一个.csv替换为空白的
本文标题:替换后缀名,只替换最后一个
本文链接:https://www.haomeiwen.com/subject/tepddltx.html
网友评论