Reputation: 3010
I think my question is quite straightforward. Examples for my case are:
ababababab
acacacacac
adadadadad
...
azazazazaz
I need a regex that can detect all the cases I mentioned above.
I have tried using:
(a\w){5}
But it doesn't work as it also passes:
abacadaeaf
Thank's for any help.
Upvotes: 3
Views: 1126
Reputation: 630
Try this : (a\w)\1+
This will match all the references of the character group occured after "a".
and \1
This backreference will do the trick.
If you want to match exact 5 groups of charcter 'ab' or 'ac' or ... then use this regex : (a\w)\1{4}
Upvotes: 3
Reputation: 30293
Use backreferences, which are supported by Oracle regular expressions:
(a\w)\1{4}
\n
refers to the nth capture group (as counted by opening parentheses).
Upvotes: 6