开发者

MySQL REGEXP repeating characters

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜