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.

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.
  • By default, replaces the first occurrence. Use the g flag in the pattern for global replacement.
  • 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 'aXbXcX'.