This article mainly introduces themysqlmethod of implementing fuzzy replacementstringbased on regular expressions. It also compares and analyzes the precautions and related issues of using regular expressions to implement mysql string replacement based on specific examples. For operational skills, friends in need can refer to
This article describes the method of fuzzy replacement of strings based on regular expressions in MySQL. Share it with everyone for your reference, the details are as follows:
For example: abcd(efg)hijk is replaced by abcdhijk
The code is as follows:
update tabaleA set name = replace(name, substring(name, locate('', name),locate(' ', name)-locate(''+10, name)),'');
After execution, an error is reported :Truncated incorrect DOUBLE value
Solution, afterqueryit was found that it isconcat(Str,'')
functionError problem, some DBs support +operator, while others cannot and must use theconcat
function.
Modify the SQL as follows:
The code is as follows:
update t_global_project set name = replace(name, substring(name, locate('', name),locate(' ', name)-locate(concat('','10'), name)),'');
The above is the detailed content of Introduction to the method of fuzzy string replacement in mysql based on regular expressions. For more information, please follow other related articles on the PHP Chinese website!