0

我的输入是这样的例子:

hxxp://192.179.110.10:82/starvision.tk?server_time=6/12/2013 6:52:53 AM&hash_value=

我想要一个 python 正则表达式,它返回第二个空格和字符之间的字符串&,在这个例子中AM

4

2 回答 2

1

表达式是

hxxp[^ ]* [^ ]* ([^&]*)&

第 1 组将包含您的“am”

于 2013-06-13T03:19:06.790 回答
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']
于 2013-06-13T03:23:55.043 回答