File tree 1 file changed +1
-23
lines changed
1 file changed +1
-23
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ package class Parser {
113
113
return nil
114
114
}
115
115
116
- let groups : [ String ] = line . captureGroup ( with : captureGroupType . pattern )
116
+ let groups : [ String ] = captureGroupType . regex . captureGroups ( for : line )
117
117
guard let captureGroup = captureGroupType. init ( groups: groups) else {
118
118
assertionFailure ( )
119
119
return nil
@@ -125,25 +125,3 @@ package class Parser {
125
125
return captureGroup
126
126
}
127
127
}
128
-
129
- private extension String {
130
- func captureGroup( with pattern: String ) -> [ String ] {
131
- do {
132
- let regex = try NSRegularExpression ( pattern: pattern, options: [ . caseInsensitive] )
133
-
134
- let matches = regex. matches ( in: self , range: NSRange ( location: 0 , length: utf16. count) )
135
- guard let match = matches. first else { return [ ] }
136
-
137
- let lastRangeIndex = match. numberOfRanges - 1
138
- guard lastRangeIndex >= 1 else { return [ ] }
139
-
140
- return ( 1 ... lastRangeIndex) . compactMap { index in
141
- let capturedGroupIndex = match. range ( at: index)
142
- return substring ( with: capturedGroupIndex)
143
- }
144
- } catch {
145
- assertionFailure ( error. localizedDescription)
146
- return [ ]
147
- }
148
- }
149
- }
You can’t perform that action at this time.
0 commit comments