Home >Database >Mysql Tutorial >MySQL正则_MySQL

MySQL正则_MySQL

WBOY
WBOYOriginal
2016-06-01 13:10:331142browse

1、或

    select * from product where name regexp 'hello|world' 或

    select * from user where name regexp '[123] tom' 匹配任意一个

    其中[123]相当于 1|2|3

    select * from user where name regexp '1|2|3 tom' 

   

2、排除

    select * from user where name regexp '[^123] tom' 

 

3、范围匹配

     select * from user where name regexp '[1-3] tom'

 

4、转义特殊字符

     select * from user where name regexp 'linda//.cai'

 

5、重复元字符

      * 0个或多个   + 一个或多个 ?0个或一个

      {n}匹配n次   {n,}匹配至少n次  {n,m}匹配次数在n-m之间

      select * from product where name regexp '//([0-9] sticks?//)'

      select * from product where name regexp '[:digit:]{4}'

       

6、字符类

       [:alnum:] 任意字母和数字

       [:alpha:]  任意字符

       [:blank:] 空格和制表

       [:digit:] 任意正整数

       [:lower:] 任意小写字母

       [:upper:] 任意大写字母

       [:space:] 任意空白字符(包括空格)

 

7、定位符

       ^ 文本的开头

       $ 文本的结尾

       [[:<:>

       [[:>:]] 词的末尾

Statement:
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
Previous article:MYSQL基础命令_MySQLNext article:MySQL慢查询日志_MySQL