---
title: "replacingCharacters(in:with:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/stringprotocol/replacingcharacters(in:with:)"
---

# replacingCharacters(in:with:)

Returns a new string in which the characters in a specified range of the String are replaced by a given string.

## Declaration

```swift
func replacingCharacters<T, R>(in range: R, with replacement: T) -> String where T : StringProtocol, R : RangeExpression, R.Bound == String.Index
```
