---
cuppy_hub: salesforce
cuppy_path: reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/regexp-replace.md
cuppy_section: docs
cuppy_doc: GQ73-CCNR
cuppy_doc_uuid: 3d53c34d-295a-4193-81dd-06c32f102861
cuppy_permalink: https://cuppy.io/salesforce/d/GQ73-CCNR
cuppy_version: 1
cuppy_updated: 2026-10-23T16:16:52.575Z
cuppy_canonical: https://cuppy.io/salesforce/docs/reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/regexp-replace
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: 562795d90e4061d1ebd83485f58d0e684c4bc77ec28b5f1187c7bce7bda2d8e1
# cuppy_body_sha256 is over the document body ALONE, excluding both generated blocks.
---

> Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/regexp-replace.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.

## `REGEXP_REPLACE`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Replaces substrings matching a regular expression pattern with a replacement string.

*   `<string>`: The source string.
*   `<pattern>`: The regular expression pattern to match.
*   `<replacement>`: The replacement string.

*   `flags`: A string of option flags that modify matching behavior. Flags can be combined (for example, `'gi'`).

| Flag | Description |
| --- | --- |
| `g` | Global replacement — replace all matches, not just the first |
| `i` | Case-insensitive matching |

Returns a text value with matching substrings replaced.

*   The replacement string can contain `\N` (where N is 1-9) to insert captured groups from the pattern, or `\0` to insert the entire match. Use `\\` for a literal backslash.
*   By default, replaces only the first occurrence. Use the `g` flag for global replacement.
*   Case-insensitive matching can also come from the query’s collation; the `i` flag applies regardless of collation.
*   For detailed regex syntax, see [Regular Expression Syntax](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/string-matching.html#regular-expression-syntax).

Replace digits with a placeholder.

Returns `'fooXbar'`.

Use captured groups in the replacement.

Returns `'Smith, John'`.

Remove matching patterns by replacing with empty string.

Returns `'Hello World'` with multiple spaces reduced to one.

Replace all occurrences using the `g` flag.

Returns `'a#b#c#'`.

Use the `i` flag for case-insensitive matching.

Returns `'ThM'`.

*   [REPLACE](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/replace.html)
*   [REGEXP_SUBSTR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/regexp-substr.html)
*   [Regular Expression Syntax](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/string-matching.html#regular-expression-syntax)


---
<!-- cuppy -->
You are reading one file. The same content is free over MCP at https://cuppy.io/mcp with no signup: ranked search across all 376 documents in this hub, the merged view when you work in a layer, known workarounds matched to the error you hit, and depth control so you spend tokens on what you need. Start with the `_hello` tool. How to connect: https://cuppy.io/salesforce/ Something wrong in this document? Report it with the `session feedback` tool on the same endpoint.
<!-- /cuppy -->
