This thread is very similar to what I want: Regular Expression to split on spaces unless in quotes
But I need a few extra rules that I cannot figure out: - the above thread does split on spaces, unless they're in double quotes. However, it splits on punctuation as well. I need Anything inside the double quotes to remain as one entity.
For example:
/Update setting0 value="new value" /Save should return
/Update
setting0
value=
new value (I don't care whether it trims the quotes off or not)
/Save
/Import "C:\path\file.xml" "C:\path_2\file_2.xml" /Exit should return
/Import
C:\path\file.xml (I don't care whether it trims the quotes off or not)
C:\path_2\file_2.xml
/Exit
I ended up using this expression from the thread above:
(?<=")\w[\w\s]*(?=")|\w+|"[\w\s]*"
Could someone please help me tweak it? Thanks!