How to perform case insensitive matching? #235
Replies: 7 comments 6 replies
-
You can configure your enum Github {
static let repo = Parse {
OneOf {
Parse {
PrefixUpTo<Substring>(".git") { $0.lowercased() == $1.lowercased() }
StartsWith<Substring>(".git") { $0.lowercased() == $1.lowercased() }
}
Rest()
}
}
} Because you want to discard what's coming next, you should also use the same trick for Fortunately, the input is likely not in German, so in this case, it should be enough to compare chars by chars using |
Beta Was this translation helpful? Give feedback.
-
Oh interesting, I had no idea Prefix had that closure syntax. Thanks a lot, Thomas! And yes, that Does your snippet compile for you? I'm getting the following error and I can't quite figure out how to provide the Input generic. I'll need to dig out the video, I know I've seen it somewhere... |
Beta Was this translation helpful? Give feedback.
-
Ah, I see you noticed. It's working now :) |
Beta Was this translation helpful? Give feedback.
-
Indeed, I edited while you were responding! |
Beta Was this translation helpful? Give feedback.
-
Closing this then - merci beaucoup Thomas! |
Beta Was this translation helpful? Give feedback.
-
Almost anything that compares things in the library has a parameter where you can specify what you mean by being equal. The trailing closure syntax is a little unfortunate in this case, because you're actually parsing |
Beta Was this translation helpful? Give feedback.
-
Gonna convert this to a discussion so others may find it 😄 |
Beta Was this translation helpful? Give feedback.
-
I think I know how to solve this in principle by writing a whole new lower level parser (which will take me considerable time to wrap my head around 😅) but I'm hoping there's an easier way I don't see. What I'm trying to do get the last test case to pass:
with an updated parser:
Of course, I could stack a
in there.
That is, until
Git
comes along 🤪. There must be a better way?Beta Was this translation helpful? Give feedback.
All reactions