# REGEXREPLACE Function

> Replace text that matches a regular expression with REGEXREPLACE in TX Sheet Control: capturing groups, the occurrence to replace and case sensitivity.

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

---

Replace the text that matches a regular expression. `text` is the text to change, `pattern` the regular expression and `replacement` the new text, which can insert capturing groups as `$1`, `$2` and so on. `occurrence` 0 or omitted replaces every match, a positive number only that match, and a negative number that match counted from the end. `case_sensitivity` 0 or omitted matches case-sensitively and 1 ignores case. An invalid pattern returns `#VALUE!`.

### Syntax

```text
REGEXREPLACE(text, pattern, replacement, occurrence, case_sensitivity)
```

Category: Text. Minimum arguments: 3. Maximum arguments: 5.

Available for supported offline calculation.

### Examples

```text
=REGEXREPLACE("A1 B2","[0-9]","X")
```

The formula returns AX BX.

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:** [REGEXEXTRACT Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/regexextract/llms-full.txt)
- **Next:** [REGEXTEST Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/regextest/llms-full.txt)
