String split with " and/or ' and/or \<sep>

Kurt Mueller mu at problemlos.ch
Tue Jun 24 16:44:51 CEST 2008


Peter Otten schrieb:
> Kurt Mueller wrote:
>> How to (super)split a string (literal) containing " and/or ' and/or
>> \<sep>.
>> example:
>>
>> ' a  "  b b   "  c\ c '.supersplit(' ')
>> ->
>> ['a', '  b b   ', 'c c']
> 
>>>> import shlex
>>>> shlex.split(' a  "  b b   "  c\ c ')
> ['a', '  b b   ', 'c c']

Thanks Peter
Thanks Paul

shlex is what I was looking for.


Grüessli
-- 
Kurt Müller, mu at problemlos.ch




More information about the Python-list mailing list