python里使用正则表达式的分组命名方式
This is some text -- with punctuation.
'^(?P<first_word>\w+)'
('This',)
{'first_word': 'This'}
'(?P<last_word>\w+)\S*$'
('punctuation',)
{'last_word': 'punctuation'}
'(?P<t_word>\bt\w+)\W+(?P<other_word>\w+)'
('text', 'with')
{'t_word': 'text', 'other_word': 'with'}
'(?P<ends_with_t>\w+t)\b'
('text',)
{'ends_with_t': 'text'}
来源: http://blog.csdn.net/caimouse/article/details/78320823