Regex Match Groups

const re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
const result = re.exec('2021-04-26');
// Deconstructing from result.groups
const { year, month, day } = result.groups;
// Using array syntax
const [, year, month, day] = result;
</day></month></year>

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store