博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql-6正则表达式
阅读量:4321 次
发布时间:2019-06-06

本文共 1614 字,大约阅读时间需要 5 分钟。

mysql正则表达式

匹配的两种方式:

  • 1.模糊匹配:like
  • 2.正则表达式

    正则表达式语法:

语法 说明
^ 起始位置。如果设置了RegExp对象的Multiline属性,^也匹配'\n'或'\r'之后的位置。
$ 结束位置。如果设置了RegExp对象的Multiline属性,$也匹配'\n'或'\r'之前的位置。
. 匹配处\n之外的任何单个字符。要匹配'\n'在内的任何字符,请使用'[.\n]'模式
[...] 字符集合。匹配所包含的任意一个字符。例如'[abc]'可以匹配'plain'中的a
[^...] 负值字符集合。匹配未包含的任意字符。例如,'[^abc]'可以匹配'plain'中的'p' .这个不理解
p1|p2|p3 匹配p1或p2或p3。例如'z|food'能匹配"z"或"food"。'(z|f)ood'则匹配"zood"或"food"。
* 匹配前面的子表达式0次或多次。'zo'能匹配"z"以及"zoo".等价于{0,++}
+ 匹配前面的子表达式1次或多次。'zo+'能匹配"zo"以及"zoo",但不能匹配"z".+等价于{1,++}
{n} n是一个非负整数。匹配确定的n次。例如'o{2}'不能匹配"Bob"中的"o",但能匹配"food"中的"oo"
{n,m} m和n均为非负整数,其中n<=m。最少匹配n次且最多匹配m次
select * from csj_tbl where csj_author REGEXP "^菜鸟";select * from csj_tbl where csj_author REGEXP "教程$";select * from csj_tbl where csj_author REGEXP "^菜鸟教程$";select * from csj_tbl where csj_author REGEXP "菜鸟教程.";select * from csj_tbl where csj_title REGEXP "学习.java";select * from csj_tbl where csj_title REGEXP "学习.java......";select * from csj_tbl where csj_title REGEXP "[abc]";select * from csj_tbl where csj_title REGEXP 'java|python';-- 增加2条记录insert into csj_tbl VALUES    (6,"zood","zoozoo",2018-11-12),    (7,"food","zoozoozoozoo",2018-11-12);select * from csj_tbl where csj_title REGEXP "(z|f)ood";select * from csj_tbl where csj_title REGEXP "oo*";select * from csj_tbl where csj_title REGEXP "o+";select * from csj_tbl where csj_author REGEXP "(zoo){2}";select * from csj_tbl where csj_author REGEXP "(zoo){3,4}";select * from csj_tbl where csj_author REGEXP '[^a-z0-9]';-- 查找name字段中以元音字符开头或以'ok'字符串结尾的所有数据:select * from person_tbl where name regexp '^[aeiou]|ok$';

1418970-20181113125245478-190542039.jpg

转载于:https://www.cnblogs.com/csj2018/p/9950924.html

你可能感兴趣的文章
Linux命令学习(5):more和less
查看>>
Linux 三剑客之sed命令总结
查看>>
倒计时
查看>>
36.Altium Designer(Protel)网络连接方式Port和Net Label详解
查看>>
读《分布式一致性原理》CURATOR客户端3
查看>>
iOS 虚拟机测试出现的相关问题
查看>>
MySQL crash-safe replication(3): MySQL的Crash Safe和Binlog的关系
查看>>
mac 无法打开xx ,因为无法确认开发者身份
查看>>
简单的排序算法(冒泡、选择、插入)
查看>>
[剑指Offer] 11.二进制中1的个数
查看>>
重置报表输出选择
查看>>
ip代理池抓取qq音乐热歌前300
查看>>
Android面试题集合
查看>>
Android NDK开发
查看>>
Centos中安装和配置vsftp简明教程
查看>>
spring源码学习之AOP(一)
查看>>
AES加密算法动画演示
查看>>
三种方法实现调用Restful接口
查看>>
php第五节(字符串函数和时间、日期函数)
查看>>
magento主页限制某个目录的产品显示数量
查看>>