-
Notifications
You must be signed in to change notification settings - Fork 90
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
Nested Named Patterns/Groups #42
Comments
This can be accomplished in a few ways: match (str) {
// with my proposal in #11
someRe -> { matches: { name } }: 1
// with an as/is/of proposal
is someRe of { matches: { name } }: 1
// with static support for RegExps which might be neat...
/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/u: year + month + day
} |
Static support for RegExps discourages moving them to constants, which is sometimes better code (eg; where the same non-trivial regexp is being used more than once). Another concern to keep in mind is that if some kind of 🚲 🏚 – |
I illustrated with an example which I believe would be valid syntax using Isiah's syntax. case([1,2,3]) {
all of [first of 1,2,3] =>
} @isiahmeadows is this acceptable Isiah? |
@limeblack Close: case([1,2,3]) {
all = [first = 1, 2, 3] => ...,
}
Please do familiarize yourself with my proposal, tracked by #17 here. It has a lot of functionality in its syntax. |
Hey y'all! #65 has gotten merged, and a lot of issues have become irrelevant or significantly changed in context. Because of the magnitude of changes and subtle differences in things that seem similar, we've decided to just nuke all existing issues so we can start fresh. Thank you so much for the contributions and discussions and feel free to create new issues if something seems to still be relevant, and link to the original, related issue so we can have a paper trail (but have the benefit of that clean slate anyway). The new spec -does- talk about everything in this specific issue, though, so I think this can be considered resolved. There's even specific examples using RegExp. |
So there is a proposal currently to get named pattern groups in RegExp. I'm only really familiar with pattern matching in Mathematica so I can't comment on other languages but it would be nice if the proposal supported something like named grouped pattern matching from the get go. Matematica uses
:
which is kinda taken for obvious reasons.name : pattern.
Basically they are nested.
all
references the entire array andfirst
references 1. Here is an example using Isiah's syntax.The text was updated successfully, but these errors were encountered: