I am afraid that I do not believe that your regular expression is spelled correctly. Consider the line:
aba
We have several matches, but the fact that this is an odd length means we have to match a single a on the front panel, so:
(a)(ba)
But, unfortunately, it is not possible for your second main grouping to match (ba).
When you come across such a restriction, it was easier for me to start with the main restriction and move from there. In this case, your restriction is โodd,โ so start with
a(aa)*
to force an odd number a and go from there. :)
Greg d
source share