js substring after character code example
Example 1: javascript substring after character
// function you can use:
function getSecondPart(str) {
return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
Example 2: javascript substring after character
var testStr = "sometext-20202"
var splitStr = testStr.substring(testStr.indexOf('-') + 1);
Example 3: javascript substring after character
const str = 'sometext-20202';
const slug = str.split('-').pop();