> 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.

# RegexpReplace

The **RegexpReplace** function searches a string for a pattern and replaces all matches with the replacement string. If no matches are found, the original string is returned.

**RegExpReplace** can be useful for complex text pattern matching, or matching multiple patterns at once. For one-to-one text replacements, the **[Replace](/docs/replace)** function may also be useful.

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

```
RegexpReplace(string, pattern, replacement)
```

Function arguments:

* **string** (required): The string to search.
* **pattern** (required): The pattern to extract with.
* **replacement** (required): String to replace the sought pattern.

When your regular expression statement contains a slash, quotation or other special character, use a backslash () to escape the special character. `Regexp` can vary by database.

## 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.

## Examples

```
RegexpReplace([Product Name], "(\\d+) (\\d+mm)", "\\1-\\2")
```

Replaces every space between digits and digits preceding "mm" with a dash to indicate the range of camera lenses.

![In a table with columns Product Name and RegexpReplace, any measurement range without a dash between the two ends has one added](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/e80b8303f6e95d6c15635bf956af16073d2c9626ef484577b28043b61cce1160/assets/docs-images/94d1c88-1.png)

```
RegexpReplace([Phone Number], "(\\d{3})(\\d{3})(\\d{4})", "(\\1) \\2-\\3")
```

Transforms a phone number to (xxx) xxx-xxxx formatting.

![In a table with columns Phone Number and RegexpReplace Phone Number, unformatted numbers are broken apart with the area code in parentheses and a dash between the 6th and 7th characters](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/602a852011a83f32ce691ac578939ee2a43b8ab97fb0d282b3b952bad7beba4f/assets/docs-images/e6a3321-image.png)

```
RegexpReplace([City], "^(.*?),", "San Francisco,")
```

Replaces every character before the comma with the city in proper form.

![In a table with columns City and RegexpReplace, capitalization is corrected such that names have only their first letters capitalized](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/3b8f1ff733e84d389754de391d1f837137142c03a6211aca9c1afb503eef8488/assets/docs-images/4ae7a52-3.png)

```
RegexpReplace([Team], "[^a-zA-Z0-9\\s]", "")
```

Removes all punctuation marks in a string.

![In a table with columns Team and RegexpReplace, all punctuation is removed](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/9e343d2c3f9af072414478c16c715774c9ebc174fa665fe9e264fe814b52fdb9/assets/docs-images/6fdae7b-4.png)

```
RegexpReplace([Text], "\\/", "&")
```

Replaces the slash with "&".

![In a table with columns Text and RegexpReplace, all forward slashes are replaced with an ampersand](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/c5c5959b4bd743c2aff4e5e1da4ffc39e1f6ff04634ed626b0cab42c5296836e/assets/docs-images/ba5d1e6-5.png)

## Related resources

* [RegexpCount](/docs/regexpcount)
* [RegexpMatch](/docs/regexpmatch)
* [RegexpExtract](/docs/regexpextract)