import re for s in [ "dghnfxjdx", "aaa", "asbfd" ]: print(re.sub(r'(.+?)\1+', r'\1', s))
Standard input is empty
dghnfxjdx a asbfd
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!