^(?P<client>\S+) \S+ (?P<userid>\S+) \[(?P<datetime>[^\]]+)\] "(?P<method>[A-Z]+) (?P<request>[^ "]+)? HTTP/[0-9.]+" (?P<status>[0-9]{3}) (?P<size>[0-9]+|-) "(?P<referrer>[^"]*)" "(?P<useragent>[^"]*)"
Match:
127.0.0.1 - jg [27/Apr/2012:11:27:36 +0700] "GET /regexcookbook.html HTTP/1.1" 200 2326 "http://www.regexcookbook.com/" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
Match 1 of 1: 127.0.0.1 - jg [27/Apr/2012:11:27:36 +0700] "GET /regexcookbook.html HTTP/1.1" 200 2326 "http://www.regexcookbook.com/" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" 0 185
Group "client": 127.0.0.1 0 9
Group "userid": jg 12 2
Group "datetime": 27/Apr/2012:11:27:36 +0700 16 26
Group "method": GET 45 3
Group "request": /regexcookbook.html 49 19
Group "status": 200 79 3
Group "size": 2326 83 4
Group "referrer": http://www.regexcookbook.com/ 89 29
Group "useragent": Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) 121 63
Python 正则表达式验证Combined Log
最新推荐文章于 2022-05-07 10:20:04 发布