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

# replacingCharacters(in:with:)

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

## Declaration

```swift
func replacingCharacters(in range: NSRange, with replacement: String) -> String
```

## Parameters

- `range`: A range of characters in the receiver.
- `replacement`: The string with which to replace the characters in range.

## Return Value

Return Value A new string in which the characters in range of the receiver are replaced by replacement.

## See Also

### Related Documentation

- [replacingPercentEscapes(using:)](foundation/nsstring/replacingpercentescapes(using:).md)

### Replacing Substrings

- [replacingOccurrences(of:with:)](foundation/nsstring/replacingoccurrences(of:with:).md)
- [replacingOccurrences(of:with:options:range:)](foundation/nsstring/replacingoccurrences(of:with:options:range:).md)
