Home > Database > Mysql Tutorial > Detailed explanation of mysql's method of fuzzy replacement of strings based on regular expressions

Detailed explanation of mysql's method of fuzzy replacement of strings based on regular expressions

黄舟
Release: 2017-03-20 14:07:55
Original
2170 people have browsed it

This article mainly introduces mysqlmethods to implement fuzzy replacement strings based on regular expressions, and combines specific examples to compare and analyze the notes of using regular expressions to implement mysql string replacement. For matters and related operation skills, friends in need can refer to

. This article describes the method of fuzzy replacement of strings based on regular rules 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(&#39;<contact>&#39;, name),locate(&#39;</contact>&#39;, name)
-locate(&#39;<contact>&#39;+10, name)),&#39;&#39;);
Copy after login

After execution, an error is reported :Truncated incorrect DOUBLE value

Solution, after query, it was found that it is concat(Str,'') function error problem, some DB supports + operation symbol, and some do not have to use the concat function.

Modify the SQL as follows:

Copy code The code is as follows:

update t_global_project set name = replace(name, substring(name, locate(&#39;<contact>&#39;, name),locate(&#39;</contact>&#39;, name)
-locate(concat(&#39;<contact>&#39;,&#39;10&#39;), name)),&#39;&#39;);
Copy after login

The above is the detailed content of Detailed explanation of mysql's method of fuzzy replacement of strings based on regular expressions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template