console.log('2020-01-23'.match(/(\d{4})-(\d{2})-(\d{2})/)) const t = '2020-01-23'.match(/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/) console.log(t.groups.year) console.log(t.groups.month) console.log(t.groups.day)