@@ -118,19 +118,19 @@ extension RangeReplaceableCollection where SubSequence == Substring {
118
118
/// the given regex are replaced by another regex match.
119
119
/// - Parameters:
120
120
/// - regex: A regex describing the sequence to replace.
121
- /// - replacement: A closure that receives the full match information,
122
- /// including captures, and returns a replacement collection.
123
121
/// - subrange: The range in the collection in which to search for `regex`.
124
122
/// - maxReplacements: A number specifying how many occurrences of the
125
123
/// sequence matching `regex` to replace. Default is `Int.max`.
124
+ /// - replacement: A closure that receives the full match information,
125
+ /// including captures, and returns a replacement collection.
126
126
/// - Returns: A new collection in which all occurrences of subsequence
127
127
/// matching `regex` are replaced by `replacement`.
128
128
@available ( SwiftStdlib 5 . 7 , * )
129
129
public func replacing< R: RegexComponent , Replacement: Collection > (
130
130
_ regex: R ,
131
- with replacement: ( Regex < R . RegexOutput > . Match ) throws -> Replacement ,
132
131
subrange: Range < Index > ,
133
- maxReplacements: Int = . max
132
+ maxReplacements: Int = . max,
133
+ with replacement: ( Regex < R . RegexOutput > . Match ) throws -> Replacement
134
134
) rethrows -> Self where Replacement. Element == Element {
135
135
136
136
precondition ( maxReplacements >= 0 )
@@ -155,43 +155,43 @@ extension RangeReplaceableCollection where SubSequence == Substring {
155
155
/// the given regex are replaced by another collection.
156
156
/// - Parameters:
157
157
/// - regex: A regex describing the sequence to replace.
158
- /// - replacement: A closure that receives the full match information,
159
- /// including captures, and returns a replacement collection.
160
158
/// - maxReplacements: A number specifying how many occurrences of the
161
159
/// sequence matching `regex` to replace. Default is `Int.max`.
160
+ /// - replacement: A closure that receives the full match information,
161
+ /// including captures, and returns a replacement collection.
162
162
/// - Returns: A new collection in which all occurrences of subsequence
163
163
/// matching `regex` are replaced by `replacement`.
164
164
@available ( SwiftStdlib 5 . 7 , * )
165
165
public func replacing< R: RegexComponent , Replacement: Collection > (
166
166
_ regex: R ,
167
- with replacement : ( Regex < R . RegexOutput > . Match ) throws -> Replacement ,
168
- maxReplacements : Int = . max
167
+ maxReplacements : Int = . max ,
168
+ with replacement : ( Regex < R . RegexOutput > . Match ) throws -> Replacement
169
169
) rethrows -> Self where Replacement. Element == Element {
170
170
try replacing (
171
171
regex,
172
- with: replacement,
173
172
subrange: startIndex..< endIndex,
174
- maxReplacements: maxReplacements)
173
+ maxReplacements: maxReplacements,
174
+ with: replacement)
175
175
}
176
176
177
177
/// Replaces all occurrences of the sequence matching the given regex with
178
178
/// a given collection.
179
179
/// - Parameters:
180
180
/// - regex: A regex describing the sequence to replace.
181
- /// - replacement: A closure that receives the full match information,
182
- /// including captures, and returns a replacement collection.
183
181
/// - maxReplacements: A number specifying how many occurrences of the
184
182
/// sequence matching `regex` to replace. Default is `Int.max`.
183
+ /// - replacement: A closure that receives the full match information,
184
+ /// including captures, and returns a replacement collection.
185
185
@available ( SwiftStdlib 5 . 7 , * )
186
186
public mutating func replace< R: RegexComponent , Replacement: Collection > (
187
187
_ regex: R ,
188
- with replacement : ( Regex < R . RegexOutput > . Match ) throws -> Replacement ,
189
- maxReplacements : Int = . max
188
+ maxReplacements : Int = . max ,
189
+ with replacement : ( Regex < R . RegexOutput > . Match ) throws -> Replacement
190
190
) rethrows where Replacement. Element == Element {
191
191
self = try replacing (
192
192
regex,
193
- with: replacement,
194
193
subrange: startIndex..< endIndex,
195
- maxReplacements: maxReplacements)
194
+ maxReplacements: maxReplacements,
195
+ with: replacement)
196
196
}
197
197
}
0 commit comments