regexp_replace
Replace the first match of a regular expression in text. Pass the g option to replace every match.
Try an expression
In Formula, enter the expression and set Output type to VARCHAR.
Expression
regexp_replace('hello', '[lo]', '-')Result
'he-lo'To use your own data, replace the example values with column names. Keep format strings and other options as written.
Arguments and types
regexp_replace(string, regex, replacement, options)- string
- Text
- regex
- Text
- replacement
- Text
- options
- Text
Supported signatures (2)
regexp_replace(string: VARCHAR, regex: VARCHAR, replacement: VARCHAR) → VARCHAR
regexp_replace(string: VARCHAR, regex: VARCHAR, replacement: VARCHAR, options: VARCHAR) → VARCHARThe result type can depend on the input types. See DuckDB for the full argument rules.
Things to know
Only the first match is replaced by default. Add the fourth argument 'g' to replace every match.
If the first argument is missing, the result is NULL.
Replace every match
regexp_replace('hello', '[lo]', '-', 'g')'he---'
Function metadata from DuckDB, used under the MIT license.