-
Notifications
You must be signed in to change notification settings - Fork 50
Initial matcher/validator support #122
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
Conversation
} | ||
|
||
func testMatchReplace() { | ||
let regex = Regex(OneOrMore(.digit).capture { Int($0)! }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great if we get additional examples of find-and-replace with a regex with multiple captures, both with the regex literal and with the result builder syntax. That will help inform our decisions around Swift tuples vs nominal tuples.
511d216
to
e89dcbb
Compare
@swift-ci Please test Linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -9,56 +9,54 @@ | |||
// | |||
//===----------------------------------------------------------------------===// | |||
|
|||
import _MatchingEngine | |||
public struct RegexConsumer< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me for now.
Outside scope of this PR, we might make RegexProtocol itself a consumer/searcher/matcher. But, I think it's best to establish parent-child relationships after we have the fundamental model in place. The important thing is getting this code and conformances in.
BTW, why does this need to be public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some consumer/searcher algorithms return a type generic over the searcher, so the regex overloads return a type generic over RegexConsumer
. So same story as PredicateConsumer
at the moment.
* Initial matchers support * Conform `RegexConsumer` to the matcher protocols * Add `firstMatch`/`lastMatch` and match find/replace * Add `_MatchResult` and allow `RegexProtocol` in algorithms
Adds
MatchingCollectionConsumer
andMatchingCollectionSearcher
as a matching/validating analogues ofCollectionConsumer
andCollectionSearcher
:...as well as matching equivalents of the other consumer/searcher protocols.
Also adds a few algorithms that work with matches:
firstMatch
/lastMatch
matches(of:)
replacing(_:with:)
using a closure: