import rerx = r"(a.*?c)?.*g"s = "abcdefg"m = re.search(rx, s)if m: print(m.group(0)) print(m.group(1))
Standard input is empty
abcdefg abc
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!