Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing named capture groups in String#matchAll #613

Closed
cruzdanilo opened this issue Aug 9, 2019 · 1 comment
Closed

missing named capture groups in String#matchAll #613

cruzdanilo opened this issue Aug 9, 2019 · 1 comment

Comments

@cruzdanilo
Copy link

the groups property of the regex matches is undefined.

const string = 'Favorite GitHub repos: tc39/ecma262 v8/v8.dev';
const regex = /\b(?<owner>[a-z0-9]+)\/(?<repo>[a-z0-9\.]+)\b/g;
for (const match of string.matchAll(regex)) {
  console.log(`${match[0]} at ${match.index} with '${match.input}'`);
  console.log(`→ owner: ${match.groups.owner}`);
  console.log(`→ repo: ${match.groups.repo}`);
}

error:

TypeError: Cannot read property 'owner' of undefined

example from: https://v8.dev/features/string-matchall

@zloirock
Copy link
Owner

zloirock commented Aug 9, 2019

It's a duplicate of #521.

@zloirock zloirock closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants