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
- Python | Consecutive Maximum Occurrence in list
- Python | Find last occurrence of substring
- Python | Get the string after occurrence of given substring
- Python | Ways to find nth occurrence of substring in a string
- Python - Consecutive Alphabetic Occurrence
- Python | Find longest consecutive letter and digit substring
- Generate two output strings depending upon occurrence of character in input string in Python
- Python program to remove Nth occurrence of the given word
- Python | Last occurrence of some element in a list
- Python | Replace multiple occurrence of character by single
- Python | First occurrence of True number
- Python | Count occurrence of all elements of list in a tuple
- Python | Percentage occurrence at index
- Python | Element Occurrence in dictionary of list values
- Python | Count tuples occurrence in list of tuples
- Python | Sort tuple based on occurrence of first element
- Python | Add the occurrence of each number as sublists
- Python program to find occurrence to each character in given string
- Python | Split on last occurrence of delimiter
- Python | Split string on Kth Occurrence of Character
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.