| The code is as follows |
Copy Code |
Update comment set url=if (url REGEXP ' test.yahoo.com.cn ', replace (URL, ' www1.www.111cn.net ', ' www.sina.com '), replace ( URL, ' www2.yahoo.com ', ' www.sina.com ') where 1=1; Update comment Set Author_url=replace (author_url, ' Hzhuti ', ' Sina ') where Author_url REGEXP ' www.111cn.net '; |
$ match End of string
$sql = "Select ' Fonfo ' REGEXP ' ^fo$ ' from String_find";
. Match any character (including carriage return and new line)
$sql = "Select ' Fofo ' REGEXP ' ^f.*$ ' from String_find";
A * matches any sequence of 0 or more a characters
$sql = "Select ' Ban ' REGEXP ' ^ba*n ' from String_find";
A + matches any sequence of 1 or more a characters
$sql = "Select ' Ban ' REGEXP ' ^ba+n ' from String_find";
A? Match 0 or 1 a characters
$sql = "Select ' Bn ' REGEXP ' ^ba?n ' from String_find";
DE|ABC matching sequence de or ABC
(ABC) * matches 0 or more instances of the sequence ABC.
{1}, {2,3} {n} or {m,n} notation provides a more general way to write regular expressions that can match many of the aforementioned atoms (or "parts") of a pattern. M and n are all integers.
O *
Can be written as a{0,}.
O +
Can be written as A{1,}.
o A?
Can be written to a{0,1}.
More accurately, a{n} matches exactly the n instances of a. A{n,} matches N or more instances of a. A{m,n} matches a m~n instance of a, containing M and N.
M and n must be in the range of 0~re_dup_max (default 255), containing 0 and Re_dup_max. If both the M and n,m must be less than or equal to
[A-DX], [^A-DX] matches any character that is (or is not, if used ^) A, B, C, D, or X. The "-" character between two other characters constitutes a range that matches all characters from the beginning of the 1th character to the 2nd character. For example, [0-9] matches any decimal digit. To include the literal character "]", it must be immediately after the opening parenthesis "[". To include the literal character "-", it must be written first or last. for [] Any character that does not have any special meaning defined internally, only matches itself.
To illustrate how an extended regular expression works, the like query shown above uses the REGEX p rewrite below:
1. In order to find the name that begins with "B", use "^" to match the beginning of the first name and "[BB]" to match lowercase or uppercase "B":
Mysql> select * FROM pet WHERE name REGEXP "^[BB]";
2. In order to find the name ending with "FY", use "$" to match the end of the name:
Mysql> select * FROM pet WHERE name REGEXP "fy$";
3. In order to find the name containing exactly 5 characters, use "^" and "$" to match the start and end of the first name, and the 5 "." Instances in between:
Mysql> select * FROM pet WHERE name REGEXP "^.....$";
4, you can also use the "{n}" "Repeat n Times" operator to rewrite the previous query:
Mysql> SELECT * from pet WHERE name REGEXP "^. {5}$ ";
For more details please see: http://www.111cn.net/database/110/a2a1c451484e5b4f5df0f988c9fad971.htm