---
name: "regexFind"
type: command
status: ok
groups: ["Strings - Regular Expression"]
arma3_since: "2.06"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/regexFind
revid: 369430
updated: 2024-09-03T18:48:53Z
---

# regexFind

*Command · Strings - Regular Expression · Arma 3 v2.06*

## Description

Searches in a string with a regular expression.

> [!NOTE]
> See Arma 3: Regular Expressions.

## Syntax

```sqf
haystack regexFind [pattern, startOffset]
```

**Parameters:**

- `haystack`: [String](../topics/String.md)
- `pattern`: [String](../topics/String.md) - format regex pattern
- `startOffset`: [Number](../topics/Number.md) - (Optional, default 0) has to be in range from 0 to `count haystack` (*haystack*'s length)

**Returns:** [Array](../topics/Array.md) of nested arrays. Each lowest level array in format:
- 0: [String](../topics/String.md) - match
- 1: [Number](../topics/Number.md)  - offset of given match relative to *haystack* beginning (the provided *offset* is ignored)

## Examples

### Example 1

```sqf
"wooKie boOkie cookie" regexFind [".ookie/gio"]; // [[["wooKie", 0]], [["boOkie", 7]], [["cookie", 14]]]
```

### Example 2

```sqf
"wooKie boOkie cookie" regexFind [".ookie/i"]; // [[["wooKie",0]]]
```

### Example 3

```sqf
"wooKie boOkie cookie" regexFind [".ookie/"]; // [[["cookie", 14]]]
```

### Example 4

Multiline example:

```sqf
"co1kie2
co2kie" regexFind ["^co.kie$"]; // [[["co2kie",9]]]
```

### Example 5

```sqf
"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e/i"]; // [[["cookie",6], ["oo", 7], ["i", 10]]]
```

### Example 6

```sqf
"I'm a cookie clicker" regexFind ["c(.*?)k(.*?)e"]; // [[["cookie", 6], ["oo", 7], ["i", 10]], [["clicke", 13], ["lic", 14], ["", 18]]]
```

## See also

[regexMatch](../commands/regexMatch.md) · [regexReplace](../commands/regexReplace.md)

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