How to match strings of the form
"a"*m + "b"*n
With the constraint that m > n > 0
.
Example matches:
aab
aaabb
aaaaaaaaaaaaaaaabbb
Example non-matches (violating the m > n constraint):
abb
aabb
aaaabbbb
I was able to do this in perl by using a recursive subpattern. But in Python that feature doesn't work:
>>> re.match("^a+(a(?1)?b)$", "aaabb")
error: unknown extension ?1 at position 6
Is there any way to do this in stdlib Python re
module, or is there another pattern possible which doesn't require an external PCRE library?