1# test match.groups() 2 3try: 4 import ure as re 5except ImportError: 6 try: 7 import re 8 except ImportError: 9 print("SKIP") 10 raise SystemExit 11 12try: 13 m = re.match(".", "a") 14 m.groups 15except AttributeError: 16 print("SKIP") 17 raise SystemExit 18 19 20m = re.match(r"(([0-9]*)([a-z]*)[0-9]*)", "1234hello567") 21print(m.groups()) 22 23m = re.match(r"([0-9]*)(([a-z]*)([0-9]*))", "1234hello567") 24print(m.groups()) 25 26# optional group that matches 27print(re.match(r"(a)?b(c)", "abc").groups()) 28 29# optional group that doesn't match 30print(re.match(r"(a)?b(c)", "bc").groups()) 31 32# only a single match 33print(re.match(r"abc", "abc").groups()) 34