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.
16 lines
270 B
JavaScript
16 lines
270 B
JavaScript
var re = /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/;
|
|
|
|
var result = "1999-09-29".match(re);
|
|
|
|
expect(result.groups).toEqual({
|
|
year: "1999",
|
|
month: "09",
|
|
day: "29",
|
|
});
|
|
|
|
expect(result.groups).toEqual({
|
|
year: result[1],
|
|
month: result[2],
|
|
day: result[3],
|
|
});
|