Answers for "js replace last character"

75

js remove last character from string

let str = "Hello Worlds";
str = str.slice(0, -1);
Posted by: Guest on January-16-2020
1

javascript replace last character

var str1 = "Notion,Data,Identity,".replace(/.$/,".")
Posted by: Guest on April-28-2021
1

javascript remoe last character from string

let str = "12345.00";
str = str.substring(0, str.length - 1);
Posted by: Guest on November-14-2020
0

javascript replace last occurrence of a letter

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);
Posted by: Guest on May-31-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language