I need to find consecutive (non-overlapping) repetitions of a substring in a string. I can count them but not consecutive. For instance:
string = "AASDASDDAAAAAAAAERQREQREQRAAAAREWQRWERAAA"
substring = "AA"
here, "AA" is repeated one time at the beginning of the string, then 4 times, then 2 times, etc.
I should select the biggest one, in this example - 4 times.
How can I do that?