<pattern>: The regular expression pattern to match.
<replacement>: The replacement string.
Optional
flags: A string of option flags that modify matching behavior. Flags can be combined (for example, 'gi').
Flags
Flag
Description
g
Global replacement — replace all matches, not just the first
i
Case-insensitive matching
Returns
Returns a text value with matching substrings replaced.
Considerations
The replacement string can contain \N (where N is 1-9) to insert captured groups from the pattern, or \0 to insert the entire match. Use \\ for a literal backslash.
By default, replaces only the first occurrence. Use the g flag for global replacement.
Case-insensitive matching can also come from the query’s collation; the i flag applies regardless of collation.