import rep = re.compile(r'(AA|BB)(.*)\1')test_str = "AA text AA"print([x.group(2).strip() for x in p.finditer(test_str)])
Standard input is empty
['text']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!