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:

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.

Similar Reads

MariaDB REPLACE String Function

The REPLACE function is used to replace all the occurrences of a substring with some other string....

Example of REPLACE() Function

The following query replaces World with GeeksforGeeks....

MariaDB REGEXP_REPLACE() Function

The REGEXP_REPLACE() function replaces all occurrences of a substring that matches the regex pattern with another string....

Examples of Updating Columns by Replacing Substringsin MariaDB

We will ccreatea table and aaddsome records data to the table....

Conclusion

Overall After readingthe whole articl,e you havea good understandingof How to UPDATE and REPLACE part of a string in MariaDB, We have seen the variousmethodsd along with the output and explanation of output. Now you can perform various queries to REPLACE part of a string in MariaDB....