正则表达式从文本文件中提取用户代理和浏览器

时间:2017-06-01 19:46:48

标签: php regex

    • Mozilla / 5.0(Windows NT 6.1; WOW64; rv:11.0)Gecko / 20100101 Firefox / 11.0

1 个答案:

答案 0 :(得分:0)

\ d + \ \ d + \ \ d + \ \ d +)[\ S - ] +(\ [* \。])[\ S&#34]。。。????+(\ W +)\ S +([^ \ s] +)\ s +(?[^ \ s] +)[\ s"] +(?\ d +)\ s +(?\ d +)([ - ] +(?[。*]]))? /米&#39 ;;  $ str =' 115.241.154.148 - - [31 / Mar / 2012:18:09:53 +0530] GET / HTTP / 1.1 200 1131 - Mozilla / 4.0(兼容; MSIE 6.0; Windows 98) 117.199.7.144 - [31 / Mar / 2012:19:32:37 +0530] GET / HTTP / 1.1 304 - - Mozilla / 5.0(Windows NT 6.1; WOW64; rv:11.0)Gecko / 20100101 Firefox / 11.0 66.249.69.138 - - [31 / Mar / 2012:19:35:31 +0530] GET /robots.txt HTTP / 1.1 404 613 - Mozilla / 5.0(兼容; Googlebot / 2.1; + http://www.google。 COM / bot.html) 66.249.69.138 - - [31 / Mar / 2012:19:35:31 +0530] GET /kuhsonline/main/head.php HTTP / 1.1 200 1157 - " Mozilla / 5.0(iPhone; U; CPU iPhone OS) 4_1像Mac OS X; en-us)AppleWebKit / 532.9(KHTML,如Gecko)版本/ 4.0.5 Mobile / 8B117 Safari / 6531.22.7(兼容; Googlebot-Mobile / 2.1; + http://www.google。 COM / bot.html)" 180.76.5.182 - - [31 / Mar / 2012:19:38:21 +0530] GET / HTTP / 1.1 200 1131 - Mozilla / 5.0(兼容; Baiduspider / 2.0; + http://www.baidu.com/search /spider.html)' ;; preg_match_all($ re,$ str,$ output,PREG_SET_ORDER,0); 的var_dump($输出);  ?>
相关问题