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

Peter Otten __peter__ at web.de
Tue Jun 24 05:39:28 EDT 2008


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']
> 
> 
> Thanks and Grüessli

>>> import shlex
>>> shlex.split(' a  "  b b   "  c\ c ')
['a', '  b b   ', 'c c']

Peter



More information about the Python-list mailing list