import rea = 'aaa,bbbZ,cccZZ,dddZZZ,eee'print(re.findall(r'(?:(?<!Z)Z(?:ZZ)*,+|[^,])+', a))
Standard input is empty
['aaa', 'bbbZ,cccZZ', 'dddZZZ,eee']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!