http://blog.csdn.net/pipisorry/article/details/46619179
re模块匹配规则见:http://blog.csdn.net/pipisorry/article/details/25909899
日志分析时,假设给定的字符串:
char str = “10.10.1.1 [2015/04/22 +0800] /ab/cd/?test0=123&test2=234 xxxx”; 要从中获取2015/04/22、/ab/cd/和234等值。
str = “10.10.1.1 [2015/04/22 +0800] /ab/cd/?test0=123&test2=234 xxxx”
print(re.findall(“\d{4}/\d{2}/\d{2}|/\w{2}/\w{2}|(?<=test2=)\d+”, str))
printurl,”url error”
from:http://blog.csdn.net/pipisorry/article/details/46619179
ref:
原文地址:http://blog.csdn.net/pipisorry/article/details/46619179