Skip to main content

REGEXP_REPLACE function

Replaces all substrings of str that match the regular expression pattern with rep.

Note

CeloSQL uses Java regex patterns.

Syntax

REGEXP_REPLACE( str, pattern, rep, [ position ] )

Arguments

  • str: A VARCHAR expression to be matched

  • pattern: A VARCHAR literal with a regular expression pattern

  • rep: A VARCHAR expression to replace all matched substrings.

  • position: Optional. The number of characters from the first to start matching.

Returns

A VARCHAR.

Examples

> SELECT regexp_replace('VEND - 1234567 WILLY WONKA', '(\d+)', '89');
'VEND - 89 WILLY WONKA'

> SELECT regexp_replace('hello world', 'goodbye.*', 'hello');
'hello world'