File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Sources/_StringProcessing/Regex Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ extension BidirectionalCollection where SubSequence == Substring {
164
164
public func wholeMatch< R: RegexComponent > (
165
165
of r: R
166
166
) -> Regex < R . RegexOutput > . Match ? {
167
- try ? r. regex. wholeMatch ( in: self [ ... ] . base )
167
+ try ? r. regex. wholeMatch ( in: self [ ... ] )
168
168
}
169
169
170
170
/// Checks for a match against the string, starting at its beginning.
Original file line number Diff line number Diff line change @@ -170,6 +170,16 @@ class AlgorithmsResultBuilderTests: XCTestCase {
170
170
}
171
171
172
172
func testMatches( ) throws {
173
+ do {
174
+ let regex = Regex { OneOrMore ( . any) }
175
+ XCTAssertEqual ( " abc " . wholeMatch ( of: regex) !. 0 , " abc " )
176
+ XCTAssertEqual ( " abc " . prefixMatch ( of: regex) !. 0 , " abc " )
177
+ XCTAssertEqual ( " abc " . firstMatch ( of: regex) !. 0 , " abc " )
178
+ XCTAssertEqual ( " abc " . suffix ( 1 ) . wholeMatch ( of: regex) !. 0 , " c " )
179
+ XCTAssertEqual ( " abc " . suffix ( 1 ) . prefixMatch ( of: regex) !. 0 , " c " )
180
+ XCTAssertEqual ( " abc " . suffix ( 1 ) . firstMatch ( of: regex) !. 0 , " c " )
181
+ }
182
+
173
183
let int = Capture ( OneOrMore ( . digit) ) { Int ( $0) ! }
174
184
175
185
// Test syntax
You can’t perform that action at this time.
0 commit comments