<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextFinderClient/shouldReplaceCharacters(inRanges:with:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextFinderClient(im)shouldReplaceCharactersInRanges:withStrings:"
  },
  "title" : "shouldReplaceCharacters(inRanges:with:)"
}
-->

# shouldReplaceCharacters(inRanges:with:)

Returns whether the specified strings should be replaced.

```
optional func shouldReplaceCharacters(inRanges ranges: [NSValue], with strings: [String]) -> Bool
```

## Parameters

`ranges`

The ranges of the strings to replace.

`strings`

The replacement strings.

## Return Value

Returns <doc://com.apple.documentation/documentation/Swift/true> if the replacement should occur; otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

See [`NSTextFinder`](/documentation/AppKit/NSTextFinder) for a complete description.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)