Declaration
REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])
Description
Replaces all substrings in the string expr that match the pattern pat with the string specified by repl, and returns the resulting string. If expr, pat, or repl is NULL, the function returns NULL.
pos: The position in the expressionexprfrom which to start the search. The default value is1.occurrence: specifies the number of times to perform the replacement. The default value is0, which means all matching substrings will be replaced.match_typespecifies the matching rule. For more information about matching rules, see REGEXP_LIKE.
Examples
obclient> SELECT REGEXP_REPLACE('OceanBase', 'a', '2');
+---------------------------------------+
| REGEXP_REPLACE('OceanBase', 'a', '2') |
+---------------------------------------+
| Oce2nB2se |
+---------------------------------------+
1 row in set
obclient> SELECT REGEXP_REPLACE('OceanBase', 'a', '2',7);
+-----------------------------------------+
| REGEXP_REPLACE('OceanBase', 'a', '2',7) |
+-----------------------------------------+
| OceanB2se |
+-----------------------------------------+
1 row in set
obclient> SELECT REGEXP_REPLACE('OceanBase', 'a', '2',1,2);
+-------------------------------------------+
| REGEXP_REPLACE('OceanBase', 'a', '2',1,2) |
+-------------------------------------------+
| OceanB2se |
+-------------------------------------------+
1 row in set