# RegexpExtract

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

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, Analytics Pro returns the first capture group across all matches. Otherwise, Analytics Pro returns the full regular expression.

### Usage

```
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 contains a slash, quotation or other special character, use a backslash (\\) to escape the special character. Regexp can vary based on the database. Check the documentation of the database you use to find the correct syntax.

### Examples

**Example 1:**

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

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

<figure><img src="https://files.readme.io/da9baf7-1.png" alt=""><figcaption></figcaption></figure>

**Example 2:**

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

Extracts the second match of numeric characters in the string.&#x20;

<figure><img src="https://files.readme.io/17d232e-2.png" alt=""><figcaption></figcaption></figure>

**Example 3:**

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

Extracts the second match of alphabetical characters in the string.

<figure><img src="https://files.readme.io/77b7734-3.png" alt=""><figcaption></figcaption></figure>

**Example 4:**

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

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

<figure><img src="https://files.readme.io/07f6765-4.png" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.meetuma.ai/uma-knowledgebase/data-and-reporting/analytics-pro/functions/text-functions/regexpextract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
