Skip to main content
Skip to main content

REGEXP_REPLACE_ONE

regexp_replace_one​

description​

Syntax​

VARCHAR regexp_replace_one(VARCHAR str, VARCHAR pattern, VARCHAR repl)

Regular matching of STR strings, replacing the part hitting pattern with repl, replacing only the first match.

example​

mysql> SELECT regexp_replace_one('a b c', " ", "-");
+-----------------------------------+
| regexp_replace_one('a b c', ' ', '-') |
+-----------------------------------+
| a-b c |
+-----------------------------------+

mysql> SELECT regexp_replace_one('a b b','(b)','<\\1>');
+----------------------------------------+
| regexp_replace_one('a b b', '(b)', '<\1>') |
+----------------------------------------+
| a <b> b |
+----------------------------------------+

keywords​

REGEXP_REPLACE_ONE,REGEXP,REPLACE,ONE