# REGEXEXTRACT Function

> Extract text that matches a regular expression with REGEXEXTRACT in TX Sheet Control: first match, all matches, capturing groups and case sensitivity.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > REGEXEXTRACT Function
- **236 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/regexextract/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/regexextract/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/regexextract/llms-full.txt

---

Extract the text that matches a regular expression. `text` is the text to search and `pattern` the regular expression. `return_mode` selects the result: 0 the first match (the default), 1 all matches as an array, or 2 the capturing groups of the first match as an array. `case_sensitivity` 0 or omitted matches case-sensitively and 1 ignores case. No match returns `#N/A`, and an invalid pattern or `return_mode` returns `#VALUE!`.

### Syntax

```text
REGEXEXTRACT(text, pattern, return_mode, case_sensitivity)
```

Category: Text. Minimum arguments: 2. Maximum arguments: 4.

Available for supported offline calculation.

### Examples

```text
=REGEXEXTRACT("TX42","[0-9]+")
```

The formula returns 42.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [REDUCE Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/reduce/llms-full.txt)
- **Next:** [REGEXREPLACE Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/regexreplace/llms-full.txt)
