MySQL doesn't support it natively, but this is possible if you install the user-defined functions from the lib_mysqludf_preg library.
You should be able to then do something like this:
UPDATE table_name
SET column_name = PREG_REPLACE('regex_match', 'replacement_value', column_name);
This is third-party software but it uses the standard MySQL User-defined function interface to enable custom functions written in C/C++ to interact and behave like built-in functions (e.g., REPLACE()
) ... but UDFs are essentially plug-ins that can be installed and uninstalled without having to recompile the server or even having to shut it down and restart.
Above, the 'regex_match' and 'replacement_value' are the regular expression and replacement values, which can be from columns, variables, or supplied in the query as string literals. In the last case, they need to be quoted.