REGEXP_REPLACE
Replaces a matching substring with replacement string.
See also:
[SELECT] [ Regular Expression 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.
Supports backreferences to captured groups
\1through\9in replacement string.
Return Value(s)
Returns a string.
Examples
Replace a regular expression pattern in a column
- StackQL
- Results
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';
|------|--------------|
| name | date_created |
|------|--------------|
| vm0 | 2022-09-14 |
|------|--------------|
| vm1 | 2022-09-14 |
|------|--------------|
| vm2 | 2022-09-14 |
|------|--------------|
For more information, see https://github.com/nalgeon/sqlean/blob/main/docs/re.md