add pattern operators
rkh opened this issue · 6 comments
- union operator:
Pattern#|
- concatenation:
Pattern#+
- negation
- exclusion
union would be great, like in groups (a|b)
Oh, you mean in the syntax? This issue was meant for on the pattern objects. I think a syntax extension should go into a separate issue.
I see, do you have plans on extending the sinatra syntax to also support some operators? I am using this lib for some (non-sinatra) project where I am doing a lot of pattern matching/capturing and I like the flexibility very much. However I miss a way to specify alternatives in the syntax like /a|b/. The only possibilities are shell (but then no capturing) or regular expressions.
Yes, I would consider that. I just meant that we probably want to open a separate issue for that.
Back to this topic:
- Operators should be usable for patterns of different types, creating composed pattern objects if needed.
- If both patterns are expandable, resulting pattern should be expandable, too.
Exclusion should be solved via negation.