fork download
  1. import re
  2. rx = r"(a.*?c)?.*g"
  3. s = "abcdefg"
  4. m = re.search(rx, s)
  5. if m:
  6. print(m.group(0))
  7. print(m.group(1))
  8.  
Success #stdin #stdout 0s 23304KB
stdin
Standard input is empty
stdout
abcdefg
abc