@@ -67,16 +67,18 @@ extension RangeReplaceableCollection {
67
67
// MARK: Fixed pattern algorithms
68
68
69
69
extension RangeReplaceableCollection where Element: Equatable {
70
- /// Returns a new collection in which all occurrences of a target sequence
71
- /// are replaced by another collection.
70
+ /// Returns a new collection in which all occurrences of the given collection
71
+ /// are replaced.
72
+ ///
72
73
/// - Parameters:
73
- /// - other: The sequence to replace.
74
- /// - replacement: The new elements to add to the collection.
74
+ /// - other: The collection to to search for and replace.
75
+ /// - replacement: The new elements to add to the collection in place of
76
+ /// `other`.
75
77
/// - subrange: The range in the collection in which to search for `other`.
76
78
/// - maxReplacements: A number specifying how many occurrences of `other`
77
- /// to replace. Default is `Int.max` .
79
+ /// to replace .
78
80
/// - Returns: A new collection in which all occurrences of `other` in
79
- /// `subrange` of the collection are replaced by `replacement`.
81
+ /// `subrange` are replaced by `replacement`.
80
82
@available ( SwiftStdlib 5 . 7 , * )
81
83
public func replacing< C: Collection , Replacement: Collection > (
82
84
_ other: C ,
@@ -91,15 +93,17 @@ extension RangeReplaceableCollection where Element: Equatable {
91
93
maxReplacements: maxReplacements)
92
94
}
93
95
94
- /// Returns a new collection in which all occurrences of a target sequence
95
- /// are replaced by another collection.
96
+ /// Returns a new collection in which all occurrences of the given collection
97
+ /// are replaced.
98
+ ///
96
99
/// - Parameters:
97
- /// - other: The sequence to replace.
98
- /// - replacement: The new elements to add to the collection.
100
+ /// - other: The collection to to search for and replace.
101
+ /// - replacement: The new elements to add to the collection in place of
102
+ /// `other`.
99
103
/// - maxReplacements: A number specifying how many occurrences of `other`
100
- /// to replace. Default is `Int.max` .
101
- /// - Returns: A new collection in which all occurrences of `other` in
102
- /// `subrange` of the collection are replaced by `replacement`.
104
+ /// to replace .
105
+ /// - Returns: A new collection in which all occurrences of `other` are
106
+ /// replaced by `replacement`.
103
107
@available ( SwiftStdlib 5 . 7 , * )
104
108
public func replacing< C: Collection , Replacement: Collection > (
105
109
_ other: C ,
@@ -113,12 +117,14 @@ extension RangeReplaceableCollection where Element: Equatable {
113
117
maxReplacements: maxReplacements)
114
118
}
115
119
116
- /// Replaces all occurrences of a target sequence with a given collection
120
+ /// Replaces all ocurrences of the given collection in this collection.
121
+ ///
117
122
/// - Parameters:
118
- /// - other: The sequence to replace.
119
- /// - replacement: The new elements to add to the collection.
123
+ /// - other: The collection to to search for and replace.
124
+ /// - replacement: The new elements to add to the collection in place of
125
+ /// `other`.
120
126
/// - maxReplacements: A number specifying how many occurrences of `other`
121
- /// to replace. Default is `Int.max` .
127
+ /// to replace .
122
128
@available ( SwiftStdlib 5 . 7 , * )
123
129
public mutating func replace< C: Collection , Replacement: Collection > (
124
130
_ other: C ,
@@ -177,16 +183,18 @@ extension RangeReplaceableCollection
177
183
// MARK: Regex algorithms
178
184
179
185
extension RangeReplaceableCollection where SubSequence == Substring {
180
- /// Returns a new collection in which all occurrences of a sequence matching
181
- /// the given regex are replaced by another collection.
186
+ /// Returns a new collection in which all matches for the given regex
187
+ /// are replaced.
188
+ ///
182
189
/// - Parameters:
183
- /// - regex: A regex describing the sequence to replace.
184
- /// - replacement: The new elements to add to the collection.
190
+ /// - regex: The collection to to search for and replace.
191
+ /// - replacement: The new elements to add to the collection in place of
192
+ /// each match for `regex`.
185
193
/// - subrange: The range in the collection in which to search for `regex`.
186
- /// - maxReplacements: A number specifying how many occurrences of the
187
- /// sequence matching `regex` to replace. Default is `Int.max` .
188
- /// - Returns: A new collection in which all occurrences of subsequence
189
- /// matching `regex` in `subrange` are replaced by `replacement`.
194
+ /// - maxReplacements: A number specifying how many occurrences of `regex`
195
+ /// to replace.
196
+ /// - Returns: A new collection in which all matches for `regex` in
197
+ /// `subrange` are replaced by `replacement`.
190
198
@available ( SwiftStdlib 5 . 7 , * )
191
199
public func replacing< R: RegexComponent , Replacement: Collection > (
192
200
_ regex: R ,
@@ -201,15 +209,17 @@ extension RangeReplaceableCollection where SubSequence == Substring {
201
209
maxReplacements: maxReplacements)
202
210
}
203
211
204
- /// Returns a new collection in which all occurrences of a sequence matching
205
- /// the given regex are replaced by another collection.
212
+ /// Returns a new collection in which all matches for the given regex
213
+ /// are replaced.
214
+ ///
206
215
/// - Parameters:
207
- /// - regex: A regex describing the sequence to replace.
208
- /// - replacement: The new elements to add to the collection.
209
- /// - maxReplacements: A number specifying how many occurrences of the
210
- /// sequence matching `regex` to replace. Default is `Int.max`.
211
- /// - Returns: A new collection in which all occurrences of subsequence
212
- /// matching `regex` are replaced by `replacement`.
216
+ /// - regex: The collection to to search for and replace.
217
+ /// - replacement: The new elements to add to the collection in place of
218
+ /// each match for `regex`.
219
+ /// - maxReplacements: A number specifying how many occurrences of `regex`
220
+ /// to replace.
221
+ /// - Returns: A new collection in which all matches for `regex` are replaced
222
+ /// by `replacement`.
213
223
@available ( SwiftStdlib 5 . 7 , * )
214
224
public func replacing< R: RegexComponent , Replacement: Collection > (
215
225
_ regex: R ,
@@ -223,13 +233,14 @@ extension RangeReplaceableCollection where SubSequence == Substring {
223
233
maxReplacements: maxReplacements)
224
234
}
225
235
226
- /// Replaces all occurrences of the sequence matching the given regex with
227
- /// a given collection.
236
+ /// Replaces all matches for the given regex in this collection.
237
+ ///
228
238
/// - Parameters:
229
- /// - regex: A regex describing the sequence to replace.
230
- /// - replacement: The new elements to add to the collection.
231
- /// - maxReplacements: A number specifying how many occurrences of the
232
- /// sequence matching `regex` to replace. Default is `Int.max`.
239
+ /// - regex: The collection to to search for and replace.
240
+ /// - replacement: The new elements to add to the collection in place of
241
+ /// each match for `regex`.
242
+ /// - maxReplacements: A number specifying how many occurrences of `regex`
243
+ /// to replace.
233
244
@available ( SwiftStdlib 5 . 7 , * )
234
245
public mutating func replace< R: RegexComponent , Replacement: Collection > (
235
246
_ regex: R ,
0 commit comments