Regular expression: same character 3 times
I want a regular expression (in php) to this (same character 3 times):
aa => false
aaa 开发者_JS百科=> true
baaa => true
aaab => true
aaaaaab => true
baaab => true
babababa => false
For any character, not only 'a' and 'b'.
You can use back-references within a regex
/(.)\1\1/
Try this regular expression:
(.)\1{2}
This will do the job :
/(.)\1\1/
精彩评论