Last active
April 25, 2017 05:49
-
-
Save DmitrySoshnikov/ad97b37ac64ea1df534e75ba2bdf70e7 to your computer and use it in GitHub Desktop.
regexp-named-groups.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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