import re s = "asbshbsbuhb" print(re.findall(r"((.)(?!\2)(.)(?!\2|\3)(.)(?!\2|\3|\4).)", s))
Standard input is empty
[('sbuh', 's', 'b', 'u')]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!