regexp_replace()

If string contains the regexp pattern, replaces the matching part with replacement. A set of optional options can be set.

Arguments & returns

2 overloads

regexp_replace(string, pattern, replacement[)

Scalar
Overload link stringpatternreplacement[ Returns
#01 VARCHARVARCHARVARCHAR VARCHAR

regexp_replace(string, pattern, replacement[, options])

Scalar
Overload link stringpatternreplacement[options] Returns
#02 VARCHARVARCHARVARCHARVARCHAR VARCHAR

Example

regexp_replace example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

In a query

Turn a label into a useful key.

Trim the edges, normalize case, and replace runs of spaces. Small functions compose into a readable cleaning step.

Turn a label into a useful key.
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Guide recipe · Run to view results.

In other engines

PostgreSQLregexp_replace()

Same function

Exasolregexp_replace()

REGEXP_REPLACE(subject, pattern, replacement, position, occurrence)
In DuckDB
REGEXP_REPLACE(subject, pattern, replacement)

SQLGlot example ↗

Snowflakeregexp_replace()

REGEXP_REPLACE(subject, pattern)
In DuckDB
REGEXP_REPLACE(subject, pattern, '', 'g')

SQLGlot example ↗