javascript substring after character code example
Example 1: get string after character javascript
const str = '01-01-2020';
const slug = str.substring(str.indexOf('-') + 1);
const slug = str.split('-').pop();
Example 2: remove first 3 characters from string javascript
var string = "abcd";
console.log(string.substring(3));
Example 3: get everything after the first character javascript
var val = 'asdasd:111122:123123123';
var response = val.substring(val.indexOf(":"));
alert(response);
Example 4: javascript substring after character
function getSecondPart(str) {
return str.split('-')[1];
}
alert(getSecondPart("sometext-20202"));
Example 5: javascript substring after character
var testStr = "sometext-20202"
var splitStr = testStr.substring(testStr.indexOf('-') + 1);
Example 6: javascript substring after character
const str = 'sometext-20202';
const slug = str.split('-').pop();