Split a string by spaces -- preserving quoted substrings -- in Python
Posted
by Adam Pierce
on Stack Overflow
See other posts from Stack Overflow
or by Adam Pierce
Published on 2008-09-17T04:25:15Z
Indexed on
2010/03/16
21:51 UTC
Read the original article
Hit count: 183
I have a string which is like this:
this is "a test"
I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is:
['this','is','a test']
PS. I know you are going to ask "what happens if there are quotes within the quotes, well, in my application, that will never happen.
© Stack Overflow or respective owner