> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REGEXP_EXTRACT

> Returns the selected capture group from the first regular-expression match.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL if value or pattern is NULL. A NULL group index can make all results NULL; use a non-NULL constant index.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
regexp_extract(value, pattern [, group])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | STRING | Yes | The string to search. |
| pattern | STRING | Yes | The regular expression. |
| group | INTEGER | No | Capture-group number. Use a non-NULL constant integer. 0 selects the entire match. Default: 1. |

## Returns

* Type: STRING
* Possible values: Matching capture text; an empty string when nothing is captured.
* NULL behavior: Returns NULL if value or pattern is NULL. A NULL group index can make all results NULL; use a non-NULL constant index.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT regexp_extract('a1b2', '([0-9])', 1) AS "value", regexp_extract('abc', '([0-9])', 1) AS no_match;
```

| value | no\_match |
| - | - |
| 1 | '' |

### Default capture group and full match

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT
  regexp_extract('a1b2', '([a-z])([0-9])') AS default_group,
  regexp_extract('a1b2', '([a-z])([0-9])', 0) AS full_match;
```

| default\_group | full\_match |
| - | - |
| a | a1 |

## Limitations

* Use a constant capture-group index. A group column is not evaluated independently for each row.
* Invalid regular expressions raise an error.
* Negative or out-of-range group indexes return an empty string.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.