Answers for "javascript trim specific character from end"

4

javascript remove specific character from string

var newString = oldString.replaceAll("character/string goes here", "");

// Example
var oldString = "Hello World!";
var newString = oldString.replaceAll("o", "");
console.log(newString);
// Prints 'Hell Wrld!' to console.
Posted by: Guest on September-08-2020
1

javascript remove period from end of string

// Single dot:
if (str[str.length-1] === ".")
    str = str.slice(0,-1);
// Multiple dots:
while (str[str.length-1] === ".")
    str = str.slice(0,-1);
// Single dot, regex:
str = str.replace(/\.$/, "");
// Multiple dots, regex:
str = str.replace(/\.+$/, "");
Posted by: Guest on March-08-2021

Code answers related to "javascript trim specific character from end"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language