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.
You want
split, from the built-inshlexmodule.This should do exactly what you want.
If you want to preserve the quotation marks, then you can pass the
posix=Falsekwarg.