实例
>>> id_num #身份证号的分组
'144731199209096719'
>>> a = re.search("([0-9]{3})([0-9]{3})([0-9]{4})",id_num)
>>> a.group() #输出匹配结果
'1447311992'
>>> a
<re.Match object; span=(0, 10), match='1447311992'>
>>> a.groups() # 元组形式输出
('144', '731', '1992')
>>> a.groupdict()
{}>>> a = re.search("(?P<name>[0-9]{3})(?P<city>[0-9]{3})(?P<birthday>[0-9]{4})",id_num)
>>> a.groupdict() # 字典形式输出
{'name': '144', 'city': '731', 'birthday': '1992'}
>>>