Dev HelpersOpen library
← Back

Extract named captures

Extract named captures. A self-contained example using the JavaScript runtime.

Open this example in the interactive library

Source code

const match = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/.exec(
  "2026-10-22",
);
console.log({ ...match.groups });

Sample output

{ year: '2026', month: '10', day: '22' }