File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Sources/_StringProcessing/RegexDSL Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,14 @@ public struct RegexMatch<Match> {
17
17
public subscript< T> ( dynamicMember keyPath: KeyPath < Match , T > ) -> T {
18
18
match [ keyPath: keyPath]
19
19
}
20
+
21
+ // Allows `.0` when `Match` is not a tuple.
22
+ @_disfavoredOverload
23
+ public subscript(
24
+ dynamicMember keyPath: KeyPath < ( Match , _doNotUse: ( ) ) , Match >
25
+ ) -> Match {
26
+ match
27
+ }
20
28
}
21
29
22
30
extension RegexProtocol {
Original file line number Diff line number Diff line change @@ -65,6 +65,11 @@ class RegexDSLTests: XCTestCase {
65
65
}
66
66
}
67
67
68
+ func testMatchResultDotZeroWithoutCapture( ) throws {
69
+ let match = try XCTUnwrap ( " aaa " . match { oneOrMore { " a " } } )
70
+ XCTAssertEqual ( match. 0 , " aaa " )
71
+ }
72
+
68
73
func testAlternation( ) throws {
69
74
do {
70
75
let regex = choiceOf {
You can’t perform that action at this time.
0 commit comments