replacing(with:subrange:maxReplacements:content:)
Returns a new collection in which all matches for the regex are replaced, using the given closure to create the regex.
Declaration
func replacing<Replacement>(with replacement: Replacement, subrange: Range<Self.Index>, maxReplacements: Int = .max, @RegexComponentBuilder content: () -> some RegexComponent) -> Self where Replacement : Collection, Replacement.Element == CharacterParameters
- replacement:
The new elements to add to the collection in place of each match for the regex, using
contentto create the regex. - subrange:
The range in the collection in which to search for the regex.
- maxReplacements:
A number specifying how many occurrences of the regex to replace.
- content:
A closure that returns the collection to search for and replace.
Return Value
A new collection in which all matches for regex in subrange are replaced by replacement, using content to create the regex.