---
title: "replaceCharacters(in:with:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstextfinderclient/replacecharacters(in:with:)"
---

# replaceCharacters(in:with:)

Replaces the text in the specified range with the new string.

## Declaration

```swift
optional func replaceCharacters(in range: NSRange, with string: String)
```

## Parameters

- `range`: The specified range of the text to replace.
- `string`: The replacement string.

## Discussion

Discussion See NSTextFinder for a complete description.

## See Also

### Replacing Text

- [shouldReplaceCharacters(inRanges:with:)](appkit/nstextfinderclient/shouldreplacecharacters(inranges:with:).md)
- [didReplaceCharacters()](appkit/nstextfinderclient/didreplacecharacters().md)
