开发者

MySQL REGEXP repeating characters

开发者 https://www.devze.com 2023-04-07 23:04 出处:网络
How can I find strings with individual repeating characters (for example 3 times)? This works but I don\'t want rewrite every alpha characters (a,b,c,d,e...):

How can I find strings with individual repeating characters (for example 3 times)?

This works but I don't want rewrite every alpha characters (a,b,c,d,e...):

开发者_高级运维

... REGEXP '(a){3}|(b){3}|(c){3}|(d){3}|(e){3}|(f){3}...' ...

Thank you very much


r = '(\w)\1{2}`

finds any alphanumeric character that is repeated (at least) three times, matching the first three.


How about repeating a capture group?

r = '([abc])\1\1'


'(abc){3}'

Example:

> echo 'bbbabcabcabcaaabbbccc' | egrep -o '(abc){3}'
abcabcabc
0

精彩评论

暂无评论...
验证码 换一张
取 消