Skip to main content
Version: Stable-3.1

regexp_replace

Description

This function uses repl to replace a sequence of characters in str that matches a regular expression pattern.

Syntax

VARCHAR regexp_replace(VARCHAR str, VARCHAR pattern, VARCHAR repl)

Examples

MySQL > SELECT regexp_replace('a b c', " ", "-");
+-----------------------------------+
| regexp_replace('a b c', ' ', '-') |
+-----------------------------------+
| a-b-c |
+-----------------------------------+

MySQL > SELECT regexp_replace('a b c','(b)','<\\1>');
+----------------------------------------+
| regexp_replace('a b c', '(b)', '<\1>') |
+----------------------------------------+
| a <b> c |
+----------------------------------------+

keyword

REGEXP_REPLACE,REGEXP,REPLACE