📌  相关文章
📜  javascript 替换最后出现的字母 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:08.662000             🧑  作者: Mango

代码示例2
String.prototype.replaceLast = function (search, replace) {
    return this.replace(new RegExp(search+"([^"+search+"]*)$"), replace+"$1");
}

str = "lala";
newStr = str.replaceLast("l", "m");
console.log(newStr);