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

Global search in regex #25

Open
rikukissa opened this issue Jul 21, 2014 · 1 comment
Open

Global search in regex #25

rikukissa opened this issue Jul 21, 2014 · 1 comment

Comments

@rikukissa
Copy link
Contributor

There's still actually one problem with this one. For example if I have a refex /a/g and the path we are matching it against is aaa then the splats params should be ["a", "a", "a"].

Now the match function actually starts looping through captures from the second element so the first match is omitted.

for (var j = 1, len = captures.length; j < len; ++j) {

So basically looping should start from the first element if the given regex is global.

Everything else would break if we just changed the looping start point.
One solution would do something like this

var j = re.global ? 0 : 1;
for (j, len = captures.length; j < len; ++j) {

Any thoughts on this? I'd be happy to create a new pull request with couple of new tests included and version number changed to 1.2.1.

PS. It's nice to see that you are responding to pull requests almost immediately!

@Raynos
Copy link
Collaborator

Raynos commented Jul 21, 2014

I understand what you mean, you would want to to have all the global captures starting from index 0.

This seems fine.

However that is a backwards compat change from the exec global semantics. So we should bump major version number. In fact i should have bumped major before instead of minor.

Let's add some more tests for this. I also really need to jump into the tests and use upgrade them to tape.

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