---
title: "search(for:direction:caseSensitive:wrap:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/webdocumentsearching/search(for:direction:casesensitive:wrap:)"
---

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

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

## Declaration

```swift
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

Return Value true if the receiver contains string in the specified direction; otherwise, false.

## Discussion

Discussion The receiver should select the string if it is found.

## See Also

### Related Documentation

- [WebKit Objective-C Programming Guide](apple-archive/documentation/Cocoa/Conceptual/DisplayWebContent.md)
