> For the complete documentation index, see [llms.txt](https://dbd-ts.gitbook.io/dbdts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dbd-ts.gitbook.io/dbdts/functions/indexof.md).

# $indexOf

Returns the character index of a 'query' within 'text'.

### Usage

```php
$indexOf[text;query]
```

This function has two params.

| Param | Description                                 | Type   | Required |
| ----- | ------------------------------------------- | ------ | -------- |
| text  | The text that gets searched for 'query'.    | String | Yes      |
| query | The phrase/character to find within 'text'. | String | Yes      |

{% hint style="danger" %}
Remember the case of characters in \`$indexOf\[]\` matters (e.g. searching for a lowercase \`h\` within \`Hello\` won't work). You can use \[\`$toLowerCase\[]\`]\(./tolowercase.md) to negate this issue.
{% endhint %}

### Examples

**Example #1**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$indexOf[hi hello hey;hey]` //Returns 10
})
```

**Example #2**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$indexOf[DBD.TS is cool.;is]` //Returns 8
})
```

**Example #3**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$indexOf[DBD.TS is cool.;DBD.TS]` //Returns 1
})
```

**Example #4**

```javascript
bot.commands.add({
    type: "basicCommand",
    name: "example",
    code: `$indexOf[This is a example text!;t]` //Returns 19
})
```
