MariaDB REGEXP_REPLACE() Function
The REGEXP_REPLACE() function replaces all occurrences of a substring that matches the regex pattern with another string.
Syntax:
REGEXP_REPLACE(string, pattern, new_substring)
Explanation:
- string: It is a string wthatis replace.
- pattern: It is a pattern to match substrings with.
- new_substring: The substring to replace the old substring.
Example
The following query replaces all occurrences of ‘and‘ with ‘or‘.
Query:
SELECT REGEXP_REPLACE('Black and blue and green','and','or') AS output;
Output:
Explanation: In the above query, We have replaced and with or in a string.
How to UPDATE and REPLACE Part of a String in MariaDB
MariaDB is one of the most popular open-source database systems. It is developed by the developers of MySQL. In this article, we will How to UPDATE and REPLACE part of a string in MariaDB along with various examples and methods and so on.