【发布时间】:2015-04-09 21:12:49
【问题描述】:
我有以下字符串。
Page load for http://xxxx?roxy=www.yahoo.com&sendto=https://mywebsite?ent took 4001 ms (Ne: 167 ms, Se: 2509 ms, Xe: 1325 ms)<br><br><br>Topic: Yahoo!! My website is a good website | Mywebsite<br>
或
Page load for http://xxxx?roxy=www.yahoo.com&sendto=https://mywebsite?ent took too long (12343 ms Ne: 167 ms, Se: 2509 ms, Xe: 1325 ms)<br><br><br>Topic: Yahoo!! My website is a good website | Mywebsite<br>
我想从ent took 4001 ms OR 中提取上面的4001 OR 12343 OR
ent took too long (12343 ms 并将其分配给变量
tt = int(re.search(r"\?ent\s*took\s*(\d+)",message).group(1))
这个正则表达式确实匹配第一部分并返回 4001。我如何在逻辑上或表达式 r"\?ent\s*\took\s*too\s*long\s*\((\d+)"
从第二部分提取12343?
【问题讨论】:
-
你看/usr/lib64/python2.7/re.py的第242行了吗?