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

1. mysql> SELECT regexp_replace_one('a b c', " ", "-");
2. +-----------------------------------+
3. | regexp_replace_one('a b c', ' ', '-') |
4. +-----------------------------------+
5. | a-b c                             |
6. +-----------------------------------+

8. mysql> SELECT regexp_replace_one('a b b','(b)','<\\1>');
9. +----------------------------------------+
10. | regexp_replace_one('a b b', '(b)', '<\1>') |
11. +----------------------------------------+
12. | a <b> b                                |
13. +----------------------------------------+

keywords

1. REGEXP_REPLACE_ONE,REGEXP,REPLACE,ONE