packages/babel-plugin-transform-named-capturing-groups-regex/test/fixtures/runtime/match-all-corejs/exec.js
raw| 1 | require('core-js/features/string/match-all.js'); |
| 2 | |
| 3 | const string = "Favorite GitHub repos: tc39/ecma262 v8/v8.dev"; |
| 4 | const regex = /\b(?<owner>[a-z0-9]+)\/(?<repo>[a-z0-9\.]+)\b/g; |
| 5 | |
| 6 | const matches = string.matchAll(regex); |
| 7 | |
| 8 | expect(matches.next().value.groups).toEqual({ |
| 9 | owner: "tc39", |
| 10 | repo: "ecma262", |
| 11 | }); |
| 12 | |
| 13 | expect(matches.next().value.groups).toEqual({ |
| 14 | owner: "v8", |
| 15 | repo: "v8.dev", |
| 16 | }); |