import re
m = re.match('(\w\w\w)-(\d\d\d)', 'abc-123')
m.group() # entire match
m.group(1) # subgroup 1
m.group(2) # subgroup 2
m.groups() # all subgroups
m = re.match('ab', 'ab') # no subgroups
m.group() # entire match
m.groups() # all subgroups
m = re.match('(ab)', 'ab') # one subgroup
m.group() # entire match
m.group(1) # subgroup 1
m.groups() # all subgroups
m = re.match('(a)(b)', 'ab') # two subgroups
m.group() # entire match
m.group(1) # subgroup 1
m.group(2) # subgroup 2
m.groups() # all subgroups
m = re.match('(a(b))', 'ab') # two subgroups
m.group() # entire match
m.group(1) # subgroup 1
m.group(2) # subgroup 2
m.groups() # all subgroups