replacing(_:with:maxReplacements:)
Returns a new collection in which all occurrences of a sequence matching the given regex are replaced by another collection.
Declaration
func replacing<Replacement>(_ regex: some RegexComponent, with replacement: Replacement, maxReplacements: Int = .max) -> Self where Replacement : Collection, Replacement.Element == CharacterParameters
- regex:
A regex describing the sequence to replace.
- replacement:
The new elements to add to the collection.
- maxReplacements:
A number specifying how many occurrences of the sequence matching
regexto replace. Default isInt.max.
Return Value
A new collection in which all occurrences of subsequence matching regex are replaced by replacement.