Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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(/.+$/, "");
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #remove #period #string
ADD COMMENT
Topic
Name
2+2 =