Contents

replace(maxReplacements:content:with:)

Replaces all matches for the regex in this collection, using the given closures to create the replacement and the regex.

Declaration

mutating func replace<Output, Replacement>(maxReplacements: Int = .max, @RegexComponentBuilder content: () -> some RegexComponent, with replacement: (Regex<Output>.Match) throws -> Replacement) rethrows where Replacement : Collection, Replacement.Element == Character

Parameters

  • maxReplacements:

    A number specifying how many occurrences of the regex to replace, using content to create the regex.

  • content:

    A closure that returns the collection to search for and replace.

  • replacement:

    A closure that receives the full match information, including captures, and returns a replacement collection.