Mysql uses regular expressions to implement fuzzy replacement of strings.
This example describes how to use regular expressions to replace strings in mysql. We will share this with you for your reference. The details are as follows:
For example, after replacing abcd (efg) hijk with abcdhijk
Copy codeThe Code is as follows: update tabaleA set name = replace (name, substring (name, locate ('<contact>', name), locate ('</contact>', name) -locate ('<contact>' + 10, name )),'');
Error: Truncated incorrect DOUBLE value
Solution: After query, it is found thatConcat (Str ,'')Function errors. Some databases support the + operator, and some cannot be used.ConcatFunction.
Modify the SQL statement as follows:
Copy codeThe Code is as follows: update t_global_project set name = replace (name, substring (name, locate ('<contact>', name), locate ('</contact>', name) -locate (concat ('<contact>', '10'), name )),'');
PS: here we will provide two very convenient Regular Expression tools for your reference:
Javascript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript
Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg