Instance Methodswift 6.0.1Swift

replaceSubrange(_:with:)

Replaces the text within the specified bounds with the given characters.

mutating func replaceSubrange<C>(_ subrange: Range<String.Index>, with newElements: C) where C : Collection, C.Element == Character

Parameters

bounds

The range of text to replace. The bounds of the range must be valid indices of the string.

newElements

The new characters to add to the string.

Calling this method invalidates any existing indices for use with this string.