`REGEXP_REPLACE`

Data 360 Query Guide, mirrored from developer.salesforce.com: **Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

markdownreferencev1GQ73-CCNRguide: data-cloud-query-guidestage: referencetrust: officialsource: developer.salesforce.comservice: data360interface: sql`REGEXP_REPLACE`Data 360Data CloudData 360 Query Guide

Created 23 Oct 2026 · Modified 23 Oct 2026 · 1 version

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').
FlagDescription
gGlobal replacement — replace all matches, not just the first
iCase-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.

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

Read this document as markdown — the same bytes an agent receives.