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 @@ -177,7 +177,7 @@ extension BidirectionalCollection where SubSequence == Substring {
177177 public func wholeMatch< R: RegexComponent > (
178178 of r: R
179179 ) -> Regex < R . RegexOutput > . Match ? {
180- try ? r. regex. wholeMatch ( in: self [ ... ] . base )
180+ try ? r. regex. wholeMatch ( in: self [ ... ] )
181181 }
182182
183183 /// Checks for a match against the string, starting at its beginning.
Original file line number Diff line number Diff line change @@ -229,6 +229,16 @@ class AlgorithmsResultBuilderTests: XCTestCase {
229229 }
230230
231231 func testMatches( ) throws {
232+ do {
233+ let regex = Regex { OneOrMore ( . any) }
234+ XCTAssertEqual ( " abc " . wholeMatch ( of: regex) !. 0 , " abc " )
235+ XCTAssertEqual ( " abc " . prefixMatch ( of: regex) !. 0 , " abc " )
236+ XCTAssertEqual ( " abc " . firstMatch ( of: regex) !. 0 , " abc " )
237+ XCTAssertEqual ( " abc " . suffix ( 1 ) . wholeMatch ( of: regex) !. 0 , " c " )
238+ XCTAssertEqual ( " abc " . suffix ( 1 ) . prefixMatch ( of: regex) !. 0 , " c " )
239+ XCTAssertEqual ( " abc " . suffix ( 1 ) . firstMatch ( of: regex) !. 0 , " c " )
240+ }
241+
232242 let int = Capture ( OneOrMore ( . digit) ) { Int ( $0) ! }
233243
234244 // Test syntax
You can’t perform that action at this time.
0 commit comments