I need to find from "aaaa" -> 'aa', 'aa', 'aa', 'aaa', 'aaa', 'aaaa'.
I tried
re.findall(r'(.)\1{1,}')
, but all I find is 'a'.
From this question, I attempted to form a regex to get the desired results. However, there are format
braces within the regex count specifier braces.
I think I've seen how that is handled but can't find it.
for n in range(1, 3):
for m in re.finditer(r'(?=((.)\2{{0}}))'.format(n), 'aaaa'):
print(m.group(1))
This gives:
a
a
a
a
a
a
a
a
but I want:
aa
aa
aa
aaa
aaa