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

keywords

  1. REGEXP_REPLACE_ONE,REGEXP,REPLACE,ONE