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

Alternation within groups #7

Open
jcgoble3 opened this issue Feb 8, 2016 · 1 comment
Open

Alternation within groups #7

jcgoble3 opened this issue Feb 8, 2016 · 1 comment

Comments

@jcgoble3
Copy link
Owner

jcgoble3 commented Feb 8, 2016

The ability to use | for regex-style alternation within groups would be nice. Probably can use a modified version of match_balance to find the end of the group, then match until encountering | or ). On success, make a recursive call to match beginning at the end of the group. If that returns success, pass it up the chain, else on NULL backtrack to the start of the group in the source string and attempt matching in the next alternative.

The major problem will be correctly counting capture groups, including capture groups passed over in unused alternatives. Also, need to handle groups that don't participate in the match (return nils in match table, but how to handle gsub() and :expand()?).

@jcgoble3
Copy link
Owner Author

From #16:

Also, I'm guaranteeing that all patterns written for stock Lua will remain compatible with the basic functions in this library as long as they do not rely on undefined behavior, and the 5.3 manual specifies that non-magic characters match themselves literally whether escaped or not, so new punctuation characters cannot be used even with an escape.

Thus, this would be limited to enhanced patterns only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant