You could use a different regex:
import re s = r' "C:\Program Files (x86)\myeditor" "$FILEPATH" -n$LINENO "c:\Program Files" -f$FILENAME -aArg2' pattern = re.compile("r"((\".+?\"\"[^\"]+\")|(\-.+?)(?:\s|$[^\s]+))") for m in re.finditer(pattern, s): print(m.group(0)) This regex will match either an item enclosed by double quotes (") or an item prepended with a dash (-).
However this might be harder to read/grasp and I'm also not sure if this is considered pythonic as it's the Perl way of doing things so take this with a grain of salt.