Syntax
REGEXP_REPLACE(expr, pat, repl[, pos[, occurrence[, match_type]]])
Purpose
Replaces substrings in the string expr that match pat with the string specified by repl and returns the modified string. If expr, pat, or repl is NULL, the function returns NULL.
posspecifies the starting position in the expressionexprfor the search, with a default value of1.occurrencespecifies the number of the match to replace withrepl. The default value of0indicates that all matching substrings are replaced.match_typespecifies the matching rules. For more information about the 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
