---
title: extractRegexAll
description: |
  Return every substring of a string that matches a regular expression, as an
  array. A pattern that does not match returns an empty array.

  The optional `group` argument works as it does in
  [`extractRegex`](extractregex.mdx): `0`, the default, returns the whole
  match, and a positive number returns that positional capture group. Unlike
  `extractRegex`, it doesn't take a capture group name.

  !!! note
      The array has one slot per match. When the requested group is optional and
      did not take part in a match, its slot is `null` rather than skipped, so
      the positions stay aligned with the matches.
url: https://coralogix.com/docs/dataprime/language-reference/functions-reference/string/extractregexall/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-12-01'
---

> Documentation index: https://coralogix.com/docs/llms.txt

# `extractRegexAll`

## Description

Return every substring of a string that matches a regular expression, as an array. A pattern that does not match returns an empty array.

The optional `group` argument works as it does in [\`extractRegex\`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/string/extractregex.md): `0`, the default, returns the whole match, and a positive number returns that positional capture group. Unlike `extractRegex`, it doesn't take a capture group name.

> **Note:**
>
> The array has one slot per match. When the requested group is optional and did not take part in a match, its slot is `null` rather than skipped, so the positions stay aligned with the matches.

## Syntax

Like many functions in DataPrime, `extractRegexAll` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference.md), **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

**Function notation**

```dataprime
extractRegexAll(value: string, pattern: regexp, group: number): array<string>
```

**Method notation**

```dataprime
(value: string).extractRegexAll(pattern: regexp, group: number): array<string>
```

## Arguments

| Name      | Type     | Required | Description                                                                                                                            |
| --------- | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `value`   | `string` | **true** | The string to search                                                                                                                   |
| `pattern` | `regexp` | **true** | The regular expression to match. Must be a literal, not a dynamic expression                                                           |
| `group`   | `number` | false    | Which part of each match to return: `0` (default) for the whole match, or `N` for the N-th positional capture group. Must be a literal |

## Example 1

**Use case: Collect every status code in a request log line**

Each match contributes one element, in the order the matches occur.

### Example query

**Function notation**

```dataprime
create str from 'GET /api/users 200, POST /login 401, DELETE /a 204'
| create codes from extractRegexAll(str, /d+/)
```

**Method notation**

```dataprime
create str from 'GET /api/users 200, POST /login 401, DELETE /a 204'
| create codes from str.extractRegexAll(/d+/)
```

### Example output

```json
{
    "codes": ["200", "401", "204"]
}
```

## Example 2

**Use case: Collect one capture group from every match**

Asking for group `1` returns that group from each match. Where the optional group did not participate, the slot holds `null`.

### Example query

**Function notation**

```dataprime
create str from 'user=alice id=42, user=bob, user=carol id=7'
| create ids from extractRegexAll(str, /user=w+(?: id=(d+))?/, 1)
```

**Method notation**

```dataprime
create str from 'user=alice id=42, user=bob, user=carol id=7'
| create ids from str.extractRegexAll(/user=w+(?: id=(d+))?/, 1)
```

### Example output

```json
{
    "ids": ["42", null, "7"]
}
```
