Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # str_longest_repeat.py - excl. non-letters
- import re
- text = 'hello12345helloworld!12345abchelloworld!xyz12345abchelloworld!'
- largest = ''
- i = 1
- while 1:
- m = re.search("(" + ("\w" * i) + ").*\\1.*\\1", text)
- if not m:
- break
- largest = m.group(1)
- i += 1
- print largest # helloworld
- print text.count(largest)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement