---
title: extractRegexAllGroups
description: |
  Return the positional capture groups of every match of a regular expression,
  as an array of arrays. A pattern that does not match returns an empty array.

  Each element holds the groups of one match, in the order the groups appear in
  the pattern. Other behavior matches
  [`extractRegexGroups`](extractregexgroups.mdx).

  !!! note
      The pattern can't contain named capture groups. A named group fails the
      query with a `named capture group` error.
url: https://coralogix.com/docs/dataprime/language-reference/functions-reference/string/extractregexallgroups/
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

# `extractRegexAllGroups`

## Description

Return the positional capture groups of every match of a regular expression, as an array of arrays. A pattern that does not match returns an empty array.

Each element holds the groups of one match, in the order the groups appear in the pattern. Other behavior matches [\`extractRegexGroups\`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/string/extractregexgroups.md).

> **Note:**
>
> The pattern can't contain named capture groups. A named group fails the query with a `named capture group` error.

## Syntax

Like many functions in DataPrime, `extractRegexAllGroups` 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
extractRegexAllGroups(value: string, pattern: regexp): array<array<string>>
```

**Method notation**

```dataprime
(value: string).extractRegexAllGroups(pattern: regexp): array<array<string>>
```

## Arguments

| Name      | Type     | Required | Description                                                                                                 |
| --------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| `value`   | `string` | **true** | The string to search                                                                                        |
| `pattern` | `regexp` | **true** | The regular expression to match. Capture groups can't be named. Must be a literal, not a dynamic expression |

## Example 1

**Use case: Read every header name and value from one string**

Each match contributes an inner array holding that match's groups.

### Example query

**Function notation**

```dataprime
create str from 'Server: nginx, Content-Type: text/html'
| create headers from extractRegexAllGroups(str, /([w-]+): ([^,]+)/)
```

**Method notation**

```dataprime
create str from 'Server: nginx, Content-Type: text/html'
| create headers from str.extractRegexAllGroups(/([w-]+): ([^,]+)/)
```

### Example output

```json
{
    "headers": [["Server", "nginx"], ["Content-Type", "text/html"]]
}
```

## Example 2

**Use case: Collect every pair of numbers in a string**

A pattern that matches nothing returns an empty array rather than `null`, so the result stays an array you can keep working with.

### Example query

**Function notation**

```dataprime
create str from '1.2 and 3.4 and 5.6'
| create pairs from extractRegexAllGroups(str, /(d+).(d+)/)
```

**Method notation**

```dataprime
create str from '1.2 and 3.4 and 5.6'
| create pairs from str.extractRegexAllGroups(/(d+).(d+)/)
```

### Example output

```json
{
    "pairs": [["1", "2"], ["3", "4"], ["5", "6"]]
}
```
