Contents

replacingOccurrences(of:with:)

Returns a new string in which all occurrences of a target string in the receiver are replaced by another given string.

Declaration

func replacingOccurrences(of target: String, with replacement: String) -> String

Parameters

  • target:

    The string to replace.

  • replacement:

    The string with which to replace target.

Return Value

A new string in which all occurrences of target in the receiver are replaced by replacement.

Discussion

Invokes replacingOccurrences(of:with:options:range:)with 0 options and range of the whole string.

See Also

Related Documentation

Replacing Substrings