get quote enclosed field in a line

Carsten Haese carsten.haese at
Fri Apr 18 01:59:24 CEST 2008

John Machin wrote:
> xahlee at wrote:
>> is there a simple way in perl, python, or awk/shell/pipe, that gets
>> the user agent field in a apache log?

> If you don't like that, just hang about -- there's sure to be a 
> pyparsing bus coming by real soon now :-)

While we're waiting for the pyparsing bus, here's the shlex train:

import shlex
line = """blah blah blah"""
print shlex.split(line)[10]


Carsten Haese

More information about the Python-list mailing list