我的输入就像这个例子:
hxxp://192.179.110.10:82/starvision.tk?server_time=6/12/2013 6:52:53 AM&hash_value=
我想要一个python正则表达式,它返回第二个空格和字符&
之间的字符串,在本例中为AM
答案 0 :(得分:1)
表达式是
hxxp[^ ]* [^ ]* ([^&]*)&
并且第1组将包含您的“am”
答案 1 :(得分:0)
>>> import re
>>> re.findall('\w+(?=&)', 'hxxp://192.179.110.10:82/starvision.tk?server_time=6/12/2013 6:52:53 AM&hash_value=')
['AM']
编辑:
>>> re.findall('server_time=[^&]+?(\w+)&', 'hxxp://192.179.110.10:82/starvision.tk?server_time=6/12/2013 6:52:53 AM&hash_value=bcd&ddd=aaa')
['AM']