Contents

stringByReplacingMatches(in:options:range:withTemplate:)

Returns a new string containing matching regular expressions replaced with the template string.

Declaration

func stringByReplacingMatches(in string: String, options: NSRegularExpression.MatchingOptions = [], range: NSRange, withTemplate templ: String) -> String

Parameters

  • string:

    The string to search for values within.

  • options:

    The matching options to use. See Matchingoptions for possible values.

  • range:

    The range of the string to search.

  • templ:

    The substitution template used when replacing matching instances.

Return Value

A string with matching regular expressions replaced by the template string.

Discussion

See Flag Options for the format of templ.

See Also

Replacing Strings Using Regular Expressions