Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Last active April 25, 2017 05:49
Show Gist options
  • Save DmitrySoshnikov/ad97b37ac64ea1df534e75ba2bdf70e7 to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/ad97b37ac64ea1df534e75ba2bdf70e7 to your computer and use it in GitHub Desktop.
regexp-named-groups.js
// Using named capturing groups:
const re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
const result = re.exec('2017-04-24');
// NOTE: need runtime support to access `groups`,
// see `useRuntime` option:
console.log(result.groups.year); // 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment