Skip to main content

regex_replace(regex, value, replacement, once)

regex_replace(regex, value, replacement, once) will try to parse value using the regular expression regex and replace with replacement. once indicates whether to replace only the first occurrence or all occurrences.

Superintendent follows Rust's regular expression syntax, which is heavily inspired by RE2.

Example 1#

SELECT regex_replace('[0-9]', '192.168.0.1', '0', false) as replaced_all

returns:

replaced_all
000.000.0.0

Example 2#

SELECT regex_replace('[0-9]', '192.168.0.1', '0', true) as replaced_first

returns:

replaced_first
092.168.0.1