Skip to main content

REGEXP_REPLACE

Replaces a matching substring with replacement string.

See also:
[SELECT] [ Regex Reference ]


Syntax​

SELECT REGEXP_REPLACE(source, pattern, replacement) FROM <multipartIdentifier>;

Arguments​

source
A literal string or string column in which matches of the regular expression pattern are replaced with replacement.

pattern
The regular expression pattern to search for.

replacement
The replacement string.

The replacement string is inserted as written: capture group references such as $1 are not expanded.

Return Value(s)​

Returns a string.


Examples​

Replace a regular expression pattern in a column​

select name,
regexp_replace(json_extract(properties, '$.timeCreated'), 'T.*', '') as date_created
from azure.compute.virtual_machines
WHERE subscription_id = '273769f6-545f-45b2-8ab8-2f14ec5768dc';

For more information, see https://github.com/google/re2/wiki/Syntax