Split string, preserve quoted substring
I have a string that I'm trying to split such that the quoted substring stays preserved. Based on another thread here, I tried using shlex:
import shlex
shlex.split('“COBRA COMMANDER” Section 4Q/C')
However, the result isn't what I expected:
['“COBRA', 'COMMANDER”', 'Section', '4Q/C']
I need the quoted text in one batch, something like:
['“COBRA COMMANDER”', 'Section', '4Q/C']
what am I doing wrong?