<!--
{
  "availability" : [
    "macOS: 10.3.0 - 10.14.0"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WebDocumentSearching/search(for:direction:caseSensitive:wrap:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WebDocumentSearching(im)searchFor:direction:caseSensitive:wrap:"
  },
  "title" : "search(for:direction:caseSensitive:wrap:)"
}
-->

# search(for:direction:caseSensitive:wrap:)

Searches for a string in a given direction from the current position.

```
func search(for string: String!, direction forward: Bool, caseSensitive caseFlag: Bool, wrap wrapFlag: Bool) -> Bool
```

## Parameters

`string`

The string to search for.

`forward`

If <doc://com.apple.documentation/documentation/Swift/true>, the search is in the forward direction from the current location; otherwise, the search is in the backward direction.

`caseFlag`

If <doc://com.apple.documentation/documentation/Swift/true> then the search is case sensitive; otherwise, it is not.

`wrapFlag`

If <doc://com.apple.documentation/documentation/Swift/true>, the search continues from the end of the document to the current location; otherwise, it stops at the end of the document.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the receiver contains `string` in the specified direction; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

The receiver should select the string if it is found.

## See Also

  [WebKit Objective-C Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DisplayWebContent/DisplayWebContent.html#//apple_ref/doc/uid/10000164i)



---

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)