# Javascript: FormattedText.find Method

> Finds a text string. The search starts at the specified position.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Method
- **Introduced:** 28.0
- **Path:** DS Server > Reference > JavaScript API > Javascript: FormattedText.find Method
- **497 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/find-method/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/find-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/find-method/llms-full.txt

---

### Description

Finds a text string. The search starts at the specified position.

### Syntax

```javascript
<void> FormattedText.find(<String> text, <Number> start, [<FindOptions> options], <RequestNumberCallback> callback, [<ErrorCallback> errorCallback])
```

### Parameters

| Parameter | Description |
|---|---|
| text | Specifies the text to search for. |
| start | Specifies the text position where the search starts, beginning with 0. If this value is -1, the search begins at the current text input position. |
| options | Optional. Specifies search options. It can be a combination of the [FindOptions](https://docs.textcontrol.com/ds-server/reference/javascript/txtextcontrol/findoptions-enumeration/llms-full.txt) values. |
| callback | If the text searched for is found, the method receives the index (zero-based) of the first character of the search string. If the specified text is not found the method receives -1. |
| errorCallback | Optional. Is called when the operation failed with an error. |

### Examples

The following example demonstrates `FormattedText.find` in a practical document-editing workflow. Finds a text string. The search starts at the specified position.

```javascript
function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.textParts.getMainText(function(formattedText) {
    formattedText.find(
        "Quarterly report",
        1,
        TXTextControl.FindOptions.Reverse,
        function(result) {
            console.log("find result:", result);
        },
        onTxError
    );
}, onTxError);
```

---

## Nearby

- **Previous:** [Javascript: FormattedText.editableRegions Property](https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/editableregions-property/llms-full.txt)
- **Next:** [Javascript: FormattedText.formFields Property](https://docs.textcontrol.com/ds-server/reference/javascript/formattedtext/formfields-property/llms-full.txt)
