const str = '01-01-2020'; // get everything after first dash const slug = str.substring(str.indexOf('-') + 1); // 01-2020 // get everything after last dash const slug = str.split('-').pop(); // 2020