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\0to insert the entire match. Use\\for a literal backslash. - By default, replaces only the first occurrence. Use the
gflag for global replacement. - Case-insensitive matching can also come from the query’s collation; the
iflag 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'.