I got word = abccabcc
and i need to find all repeating groups as follows:
regex = (.+)(.+)\1\2
so basically word = uv
where u can be: u = abc
and v can be: v = c
but using python re
lib findall()
returns only above pair but not all possible pairs such as u = ab
v = cc
.
I also tried overlapped feature in regex lib but with no success.
regex = r"(.+)(.+)\1\2"
chunkRegex = re.compile(regex)
sub = chunkRegex.findall(word)
print(sub) # [('abc', 'c')]
Exapected output for given example should be and possible there are more valid matches:
[('abc', 'c'), ('ab', 'cc'), ('a', 'bcc')]
Example in online regex matcher: https://regex101.com/r/1IZUpp/1