1const str = '01-01-2020';
2
3// get everything after first dash
4const slug = str.substring(str.indexOf('-') + 1); // 01-2020
5
6// get everything after last dash
7const slug = str.split('-').pop(); // 2020
1var val = 'asdasd:111122:123123123';
2var response = val.substring(val.indexOf(":"));
3
4alert(response); // ":111122:123123123"
1var testStr = "sometext-20202"
2var splitStr = testStr.substring(testStr.indexOf('-') + 1);
3
1// function you can use:
2function getSecondPart(str) {
3 return str.split('-')[1];
4}
5// use the function:
6alert(getSecondPart("sometext-20202"));
7