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

or() with capture() #32

Open
Tavio opened this issue Feb 1, 2015 · 0 comments
Open

or() with capture() #32

Tavio opened this issue Feb 1, 2015 · 0 comments

Comments

@Tavio
Copy link
Contributor

Tavio commented Feb 1, 2015

It seems to me that the following expression:

VerbalExpression testRegex = regex()
                .capture()
                .find("abc")
                .or("def")
                .build();

should evaluate to the regex: /(?:((?:abc)|(?:(?:def))))/, but instead it evaluates to: /(?:((?:abc))|(?:(?:def)))/. As a result, if we test this expression against the string "def" it produces a match but no group is captured. This happens because the implementation of or() closes any opening parenthesis it finds in the string that precedes it.

I don't know why or() was implemented this way, but I believe the implementation of oneOf() I propose in #31 may fix this problem.

lanwen pushed a commit that referenced this issue Feb 2, 2015
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

1 participant