File tree 2 files changed +11
-1
lines changed
Sources/_StringProcessing/Regex
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 {
177
177
public func wholeMatch< R: RegexComponent > (
178
178
of r: R
179
179
) -> Regex < R . RegexOutput > . Match ? {
180
- try ? r. regex. wholeMatch ( in: self [ ... ] . base )
180
+ try ? r. regex. wholeMatch ( in: self [ ... ] )
181
181
}
182
182
183
183
/// 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 {
229
229
}
230
230
231
231
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
+
232
242
let int = Capture ( OneOrMore ( . digit) ) { Int ( $0) ! }
233
243
234
244
// Test syntax
You can’t perform that action at this time.
0 commit comments