How would you go about splitting a normal string in to as many identical pieces as possible whilst using all characters. For example
a = \"abab\"
It seems that repeating substring has no pre and after letters, so it also could be this way:
In[4]: re.sub(r'^([a-z]+)\1$',r'\1','abab')
Out[4]: 'ab'
In[5]: re.sub(r'^([a-z]+)\1$',r'\1','ababc')
Out[5]: 'ababc'
([a-z]+) means substring, \1 means repeat.
EDIT :
re.sub(r'^([a-z]+)\1{1,}$',r'\1','abcabcabcabc')
'abc'