get quote enclosed field in a line
Penny Y.
pylists at arcor.de
Thu Apr 17 22:41:36 EDT 2008
Hello,
I don't know Python's RE very well.
But using Perl's RE you can get it.
> cat t1.pl
$x=qq{189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET
/Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org
"http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/5.0
(Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13)
Gecko/20080311Firefox/2.0.0.13" "-"};
$ua = ($x=~/\"(.+?)\"/g)[-2];
print $ua,"\n";
> perl t1.pl
Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13)
Gecko/20080311Firefox/2.0.0.13
> -----邮件原件-----
> 发件人: python-list-bounces+pylists=arcor.de at python.org
> [mailto:python-list-bounces+pylists=arcor.de at python.org] 代表
> xahlee at gmail.com
>
> e.g. the typical line is like this:
>
> 189.139.109.235 - - [07/Apr/2008:00:00:16 -0400] "GET /
> Periodic_dosage_dir/lacru/manara.html HTTP/1.1" 200 1933 xahlee.org
> "http://xahlee.org/Periodic_dosage_dir/lacru/manara2.html" "Mozilla/
> 5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.8.1.13) Gecko/20080311
> Firefox/2.0.0.13" "-"
>
> I want the part: "Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:
> 1.8.1.13) Gecko/20080311 Firefox/2.0.0.13".
More information about the Python-list
mailing list