python 正则表达式之命名分组

ip_str = "ip=230.192.168.78,version='1.0.0'"
result = re.search(r'ip=(?P<ip>\d+\.\d+\.\d+\.\d+),version=\'(?P<version>.*)\'', ip_str)
print(result.group('ip'), result.group('version'))
0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x