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

simplification error with | and a prefix #56

Open
novas0x2a opened this issue Aug 5, 2021 · 0 comments
Open

simplification error with | and a prefix #56

novas0x2a opened this issue Aug 5, 2021 · 0 comments

Comments

@novas0x2a
Copy link

$ exrex -sv '^(prefix/1|prefix/23)'
[(AT, AT_BEGINNING), (SUBPATTERN, (1, 0, 0, [(LITERAL, 112), (LITERAL, 114), (LITERAL, 101), (LITERAL, 102), (LITERAL, 105), (LITERAL, 120), (LITERAL, 47), (BRANCH, (None, [[(LITERAL, 49)], [(LITERAL, 50), (LITERAL, 51)]]))]))]
^(prefix/1|23)

$ exrex -sv '^(prefix/1|23)'
[(AT, AT_BEGINNING), (SUBPATTERN, (1, 0, 0, [(BRANCH, (None, [[(LITERAL, 112), (LITERAL, 114), (LITERAL, 101), (LITERAL, 102), (LITERAL, 105), (LITERAL, 120), (LITERAL, 47), (LITERAL, 49)], [(LITERAL, 50), (LITERAL, 51)]]))]))]
^(prefix/1|23)

Looks like it doesn't insert the () necessary to preserve the original logic (I'd probably expect something like ^(prefix/(1|23)) here). Interestingly, if I make the outer group non-capturing, it corrects the issue:

$ exrex -sv '^(?:prefix/1|prefix/23)'
[(AT, AT_BEGINNING), (LITERAL, 112), (LITERAL, 114), (LITERAL, 101), (LITERAL, 102), (LITERAL, 105), (LITERAL, 120), (LITERAL, 47), (BRANCH, (None, [[(LITERAL, 49)], [(LITERAL, 50), (LITERAL, 51)]]))]
^prefix/(?:1|23)

Otherwise, thanks for the great lib!

@novas0x2a novas0x2a changed the title simplification error with | simplification error with | and a prefix Aug 5, 2021
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