Helmut Jarausch wrote:
> Hi,
>
> I'm looking for an elegant solution to the following (quite common)
> problem:
>
> Given a string of substrings separated by white space,
> split this into tuple/list of elements.
> The problem are quoted substrings like
>
> abc "xy z"  "1 2 3"  "a \" x"
>
> should be split into  ('abc','xy z','1 2 3','a " x')

import csv

s = 'abc "xy z"  "1 2 3"  "a \\" x"'
r = iter(csv.reader([s], delimiter=" ", escapechar="\\"))
print r.next()

w.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to