I need a construction that boils down to this: "at least 1 occurrence of (substring) a, followed by the SAME number of occurrences of (substring) b". So "ab", "aaabbb" and "aaaaabbbbb" are accepted, "aab" or "aaabbbb" are not.
I found that if the number of occurrences was fixed (say 5) I could use
re.compile("a{5}b{5}")
, but I don't know the number of occurrences. I just need them to be equal.
I tried re.compile("a{x}b{x}") but that was wishful thinking I guess.