day60-mysql-正则表达式

8.正则表达式:
8.1 ^  匹配 name 名称 以 "e" 开头的数据
    select * from person where name REGEXP '^e';
 
8.2 $  匹配 name 名称 以 "n" 结尾的数据
    select * from person where name REGEXP 'n$';
 
8.3  . 匹配 name 名称 第二位后包含"x"的人员 "."表示任意字符
    select * from person where name REGEXP '.x';
 
8.4 [abci] 匹配 name 名称中含有指定集合内容的人员
    select * from person where name REGEXP '[abci]';
 
8.5 [^alex] 匹配 不符合集合中条件的内容 , ^表示取反
    select * from person where name REGEXP '[^alex]';
    #注意1:^只有在[]内才是取反的意思,在别的地方都是表示开始处匹配
    #注意2 : 简单理解 name  REGEXP '[^alex]' 等价于 name != 'alex'
 
8.6 'a|x' 匹配 条件中的任意值
    select * from person where name REGEXP 'a|x';  
 
8.7 查询以w开头以i结尾的数据
    select * from person where name regexp '^w.*i$';
    #注意:^w 表示w开头, .*表示中间可以有任意多个字符, i$表示以 i结尾
原文地址:https://www.cnblogs.com/python-daxiong/p/12313396.html