-
Notifications
You must be signed in to change notification settings - Fork 50
Add wholeMatch
and prefixMatch
#286
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
I agree that if these are on String/Substring, they should instead be generic like the others. I weakly hold that they should exist, but I appreciate @natecook1000's perspective, especially if we have anchoring modifier APIs on |
Add the functions to string processing algorithms proposal and implement the change. Move the functions from `String` and `SubString` extensions to `BidirectionalCollection`. Add tests for `firstMatch`, `wholeMatch`, and `prefixMatch` that use a custom `BidirectionalCollection` type.
00c4021
to
4b5da35
Compare
@swift-ci please test |
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, but potentially different parameter names for docs.
@@ -473,7 +484,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { | |||
/// - Returns: A new collection in which all occurrences of subsequence | |||
/// matching `regex` in `subrange` are replaced by `replacement`. | |||
public func replacing<R: RegexComponent, Replacement: Collection>( | |||
_ regex: R, | |||
_ r: R, |
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.
Why this change? It makes the doc comment above invalid
extension String { | ||
extension BidirectionalCollection where SubSequence == Substring { | ||
/// Match a regex in its entirety. | ||
/// - Parameter r: The regex to match against. |
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.
Hmm... potential parameter names could be regex
or pattern
or regexComponent
....
WDYT?
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.
Add the functions to string processing algorithms proposal and implement the
change.
Move the functions from
String
andSubString
extensions toBidirectionalCollection
. Add tests forfirstMatch
,wholeMatch
, andprefixMatch
that use a customBidirectionalCollection
type.