更新时间:2022-11-15 07:38:31
var str = 'asd-0.testing';
var regex = /(asd-)d(.w+)/;
str = str.replace(regex, "$11$2");
console.log(str);
或者,如果您确定字符串中没有任何其他数字:
Or if you're sure there won't be any other digits in the string:
var str = 'asd-0.testing';
var regex = /d/;
str = str.replace(regex, "1");
console.log(str);