When using the Python string function split(), does anybody have a nifty trick to treat items surrounded by double-quotes as a non-splitting word?
Say I want to spli
You won't be able to get this behaviour with str.split()
. If you can live with the rather complex parsing it does (like ignoring double quotes preceded by a back slash), shlex.split() might be what you are looking for:
>>> shlex.split(myStr)
['A', 'B', 'C', 'DE', 'FE', 'GH I JK L', '', '', 'O P Q', 'R']