> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# RegexpExtract

The **RegexpExtract** function returns the substring that matches a regular expression within a string.

This function isn't compatible with all data platform connections. To check if your connection supports it, see [Supported data platforms and feature compatibility](/docs/region-warehouse-and-feature-support#supported-data-platforms-and-feature-compatibility).

## Syntax

```
RegexpExtract(string, substring, [position])
```

Function arguments:

* **string** (required): The string to search
* **substring** (required): The substring to extract with.
* **position** (optional): The index of the match to return.

When the regular expression you want to use contains a slash, quotation or other special character, you will need to use a backslash () to escape the special character.

## Notes

* When any of the arguments are `Null`, the function returns `Null`.
* Regular expressions vary by database. Check the documentation of your data platform for syntax.
* If the regular expression contains a [capture group](https://docs.oracle.com/javase/tutorial/essential/regex/groups.html#:~:text=Capturing%20groups%20are%20a%20way,o%22%20and%20%22g%22%20.) (`(...)`) and there are one or more matches for that capture group, Sigma returns the first capture group across all matches

## Examples

```
RegexpExtract([Address], "[0-9]+")
```

Extracts the first match of numeric characters in the string. No position is specified so position defaults to 1.

![In a table with columns Address and RegexpExtract, the street address is extracted from the address. 345 South Court 10016 becomes 345](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/d2556519a4f71f8090f44069a3103b5960ed1414b7c8e33ba5ab887f339429d3/assets/docs-images/da9baf7-1.png)

```
RegexpExtract([Address], "[0-9]+", 2)
```

Extracts the second match of numeric characters in the string.

![In a table with columns Address and RegexpExtract, the zip code is extracted. 345 South Court 10016 becomes 10016](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/38b33becdeb7fdee0044a35990a1641c978fe06ff28c942a995a06cbaf065bde/assets/docs-images/17d232e-2.png)

```
RegexpExtract([Address], "\\s*([a-zA-Z]+)", 2)
```

Extracts the second match of alphabetical characters in the string.

![In a table with columns Address and RegexpExtract, the zip code is extracted. 345 South Court becomes Court](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/9b6bf1d938c89f2aa149733b81ffaf9b394382dbc6a45de0be040713824f126f/assets/docs-images/77b7734-3.png)

```
RegexpExtract([Date], "(\\d{2})", 2)
```

Extracts the second match, day of date, of the 2-digit character group in the date.

![In a table with columns Date and RegexpExtract, the day is extracted. 01.05.2022 becomes 05](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/9d1886b78dff95abb330ba9752ce86ee740f3c5e70188cc62dbdbb7163bcc573/assets/docs-images/07f6765-4.png)

## Related resources

* [RegexpCount](/docs/regexpcount)
* [RegexpMatch](/docs/regexpmatch)
* [RegexpReplace](/docs/regexpreplace)