Nicolò Ribaudo a27b9b4299
Add @babel/plugin-transform-named-capturing-groups-regex (#7105)
When the `runtime` flag is on (by default), this plugin adds a new helper which wraps the native `RegExp` class to provide groups support. People nees to use a polyfill (I implemented it in core-js) for browsers that don't support ES6 regexps.
2019-01-15 18:21:17 +01:00

16 lines
269 B
JavaScript

var re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
var result = re.exec("2017-12-23");
expect(result.groups).toEqual({
year: "2017",
month: "12",
day: "23",
});
expect(result.groups).toEqual({
year: result[1],
month: result[2],
day: result[3],
});