import res = '00101010111111100001011'rx = r'00[01]*?11'print([(x.start(),x.end()) for x in re.finditer(rx, s)])
Standard input is empty
[(0, 10), (15, 23)]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!