> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.itential.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server.

# indexOf

> Use the indexOf task to find the position of a specific character or group of characters within a string.

The string `indexOf` task finds the position (index) of a specific character or group of characters within a given string. By default, characters in a string are indexed from left to right. The `indexOf` task is also case-sensitive. In conjunction with other workflow tasks, this task is useful when you need to find the first instance (or all instances) of a specific character.

## Potential use case

Suppose you are attempting to extract email domains from user email addresses, and you need to isolate the exact position of the `@` symbol in the email address. Using `indexOf` will allow you to obtain the information you need.

## Properties

| Incoming      | Type   | Description                                                                                                                                           |
| ------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `str`         | String | Required. The string that contains the character value to search.                                                                                     |
| `searchValue` | String | Required. The character to search for within the `str` property.                                                                                      |
| `fromIndex`   | Number | Optional. The position (index) in the string to start the search. Numbering starts (and defaults) at position `0` (the beginning of the `str` value). |

| Outgoing | Type   | Description                                                                                                                                      |
| -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `index`  | Number | The index position in `str` where the `searchValue` first occurs. If the `searchValue` cannot be found in the string, the function returns `-1`. |

## Example 1

In this example:

* The `str` variable has been statically set as `abcabcdabcde`.
* The `searchValue` variable is `abcd`.
* The `fromIndex` is set to `0`, indicating the search should start at the beginning of the line. Numbering starts at zero.
* The output `index` will be `3`, which represents the first instance of where "abcd" can be found in the `str` variable (at character position 3).

![](/_fern-img/c8de16a1e59f229c5bcb525fc205fdde008f3901f52ac8e85526c4540ca04b45.webp)

## Example 2

In this example:

* The `str` variable has been statically set as `sales@itential.com`.
* The `searchValue` variable has been statically set as `@`.
* The `fromIndex` is set to `0`, indicating the search should start at the beginning of the line. Numbering starts at zero.
* The output `index` will be `5`, because the first instance of the value `@` occurs at character position 5 in the `str` variable.

![](/_fern-img/a70e8a1a10b7d6daf64737857c9194f55499689b1879d74b59d262e733bf56f6.webp)