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> {
1717 public subscript< T> ( dynamicMember keyPath: KeyPath < Match , T > ) -> T {
1818 match [ keyPath: keyPath]
1919 }
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+ }
2028}
2129
2230extension RegexProtocol {
Original file line number Diff line number Diff line change @@ -65,6 +65,11 @@ class RegexDSLTests: XCTestCase {
6565 }
6666 }
6767
68+ func testMatchResultDotZeroWithoutCapture( ) throws {
69+ let match = try XCTUnwrap ( " aaa " . match { oneOrMore { " a " } } )
70+ XCTAssertEqual ( match. 0 , " aaa " )
71+ }
72+
6873 func testAlternation( ) throws {
6974 do {
7075 let regex = choiceOf {
You can’t perform that action at this time.
0 commit comments