---
name: "find"
type: command
status: ok
groups: ["Strings", "Arrays"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/find
revid: 376413
updated: 2025-10-11T01:04:47Z
---

# find

*Command · Strings, Arrays · Arma 3 v0.50 · introduced in Operation Flashpoint: Elite v1.00*

## Description

Searches for an array element within an array or an ANSI string within an ANSI string.

> [!NOTE]
> **Arma 3:** If Unicode support is desired, see [forceUnicode](../commands/forceUnicode.md).

> [!IMPORTANT]
> Search is cASe-seNsItiVE!

## Syntax

### Syntax 1

```sqf
array find element
```

**Parameters:**

- `array`: [Array](../topics/Array.md) - array to search in
- `element`: [Anything](../topics/Anything.md) - array element to find

**Returns:** [Number](../topics/Number.md) - zero-based position of the first array element that matches x, -1 if not found

### Syntax 2

*since arma3 1.28*

```sqf
string find substring
```

**Parameters:**

- `string`: [String](../topics/String.md) - string to search in
- `substring`: [String](../topics/String.md) - substring to find

**Returns:** [Number](../topics/Number.md) - zero-based position of the first sequence of characters that matches substring, -1 if not found

### Syntax 3

*since arma3 2.02*

```sqf
string find [substring, indexStart]
```

**Parameters:**

- `string`: [String](../topics/String.md) - string to search in
- `substring`: [String](../topics/String.md) - substring to find
- `indexStart`: [Number](../topics/Number.md) - zero-based index which defines where find starts from

**Returns:** [Number](../topics/Number.md) - zero-based position of the first sequence of characters that matches substring, -1 if not found

## Examples

### Example 1

```sqf
["Apples", "Oranges", "Pears"] find "Oranges"; // returns 1
```

### Example 2

```sqf
[1, [2], [[3]]] find [[3]]; // returns 2 - does not work in OFP, returns -1
```

### Example 3

```sqf
if (magazines player find "Strela" != -1) then { hint "You've got Strela!"; };
```

### Example 4

```sqf
hint str ("japa is the man!" find "the man!"); // returns 8
```

### Example 5

```sqf
"abc" find ""; // returns 0
```

### Example 6

```sqf
"abcdefghijklmnopqrstuvxyz" find "z"; // returns 24
"abcdefghijklmnopqrstuvxyz" find ["z", 20]; // returns 24, better performance
```

### Example 7

```sqf
"abcßdef" find "c"; // 2
"abcßdef" find "ß"; // 3
"abcßdef" find "d"; // 5 - before forceUnicode

forceUnicode 0; // since Arma 3 v2.02
"abcßdef" find "d"; // 4
```

## See also

[in](../commands/in.md) · [findIf](../commands/findIf.md) · [forceUnicode](../commands/forceUnicode.md)

## Community notes

**Heeeere's Johnny!** — 2015-01-04

Using **[nil](../commands/nil.md)** on either side of **find** will make the whole statement return [Nothing](../topics/Nothing.md):

```sqf
_array = [1, 2, nil, 4, 5];
_result = _array find nil;
hintSilent str (isNil "_result"); // true
 
_result = nil find 1;
hintSilent str (isNil "_result"); // true
```

---

**R3vo** — 2020-07-16

If you want to return all occurences of a given string in a string use the following code. Thanks to *sharp.* for providing the code.

```sqf
private _fnc_findStringsInString =
{
    params ["_string", "_search"];
    if (_string == "") exitWith { [] };
    private _searchLength = count _search;
    private _return = [];
    private _i = 0;
    private _index = 0;
    while { _index = _string find _search; _index != -1 } do
    {
        _string = _string select [_index + _searchLength];
        _i = _i + _index + _searchLength;
        _return pushBack _i - _searchLength;
    };
    _return;
};
["Test,123,123,Test", "Test"] call _fnc_findStringsInString; // returns [0, 13]
```

<sub>Source: [BI Community Wiki — find](https://community.bistudio.com/wiki/find) (revision 376413).</sub>
