参考
实例
1.匹配以q开头的数据
Select * from test where a ~ '^q';
q,qwer,qasd
2.匹配任何单个字符 (.表示任意一个字符)
Select * from test where a ~ 'q.a';
3.匹配任意个字符(*表示零个或多个字符)
Select * from test where a ~ 'q*a';
qwa,qwwa,aqa,aqwa,aqwwwwaxx
4.匹配包含指定字符串的的文本
Select * from test where a ~ 'qa'
Aqa,aqas,aaqas,aaqaws
5.匹配包含字符集合中的任何一个字符
Select * from test where a ~ 'q[0-9]a';
q1a,q2a
6.匹配不在括号中
Select * from test where a ~ '[^0-9]'
asdf
7.匹配至少出现n次的字符串
Select * from test where a ~ 'a{3,}'
aaa,aaaa,aaaaaa
8.匹配至少出现n次,至多出现m次,如果n为0,表示为可选参数
Select * from test where a ~ 'a{1,3}';
a,aa,aaa
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




