---
title: "replace(foundTextRange:document:withText:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitextsearching-3wkjv/replace(foundtextrange:document:withtext:)"
---

# replace(foundTextRange:document:withText:)

Informs the searchable object to replace the text range for the highlighted search result.

## Declaration

```swift
func replace(foundTextRange: UITextRange, document: Self.DocumentIdentifier?, withText: String)
```

## Parameters

- `foundTextRange`: The text range to replace.
- `document`: A string that uniquely identifies a document when searching multiple documents, or nil when searching a single document.
- `withText`: The string to replace the text with.

## Discussion

Discussion When supportsTextReplacement returns YES, the system calls this method during a find session to request a text range to replace.

## See Also

### Handling replacements

- [supportsTextReplacement](uikit/uitextsearching-3wkjv/supportstextreplacement.md)
- [replaceAll(queryString:options:withText:)](uikit/uitextsearching-3wkjv/replaceall(querystring:options:withtext:).md)
- [shouldReplace(foundTextRange:document:withText:)](uikit/uitextsearching-3wkjv/shouldreplace(foundtextrange:document:withtext:).md)
