import retext = "aaaa-bb-ccc-dd"print( re.findall(r'(?=\b([A-Z]+-[A-Z]+)\b)', text, re.I) )
Standard input is empty
['aaaa-bb', 'bb-ccc', 'ccc-dd']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!