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

implement RegExp Match Indices proposal #99

Merged
merged 1 commit into from
Apr 13, 2020
Merged

Conversation

targos
Copy link
Contributor

@targos targos commented Apr 13, 2020

Refs: https://tc39.es/proposal-regexp-match-indices/

> /(?<x>a)(?<y>b)/.exec('ab')
['ab', 'a', 'b']
> /(?<x>a)(?<y>b)/.exec('ab').indices
[[0, 2], [0, 1], [1, 2]]
> /(?<x>a)(?<y>b)/.exec('ab').indices.groups
{ x: [0, 1], y: [1, 2] }

@targos
Copy link
Contributor Author

targos commented Apr 13, 2020

The diff is easier to see with ?w=1

Comment on lines +145 to +189
// TODO: add this to spec text.
groupNames.push(Value.undefined);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, the access to the values in groupNames will be off by one in MakeIndicesArray

Comment on lines +243 to +329
// TODO: fix spec text.
Assert(e >= 0/* && e < Input.length */);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e can be >= Input.length

@targos
Copy link
Contributor Author

targos commented Apr 13, 2020

/cc @rbuckton. I think I found two small bugs in the spec text.

@targos targos merged commit 27bee8f into master Apr 13, 2020
@targos targos deleted the regexp-match-indices branch April 13, 2020 20:26
@rbuckton
Copy link
Contributor

@targos can you file issues for the bugs on https://github.com/tc39/proposal-regexp-match-indices/issues?

@targos
Copy link
Contributor Author

targos commented Apr 13, 2020

@rbuckton done!

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

Successfully merging this pull request may close these issues.

3 participants