Sometimes, while working with python, we can have a problem in which we need to check for substrings occurring in consecutive repetition. This can have application in data domains. Lets discuss a way in which this task can be performed.
Method : Using
max() + re.findall()
The combination of above methods can be used to perform this task. In this, we extract the substrings repetitions using using findall() and extract the maximum of them using max().
The original string is : geeksgeeks are geeks for all geeksgeeksgeeks The maximum run of Substring : geeksgeeksgeeks
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course