Currently, I can split a string like this:
"1 2 3".split(' ') // [ "1", "2", "3" ]
"1 2 3 'word'".split(' ') // [ "1", "2", "3", "'word'" ]
Is there a way to avoid splitting on a space within a nested string?
For example:
"1 2 3 'word one'".split(' ') // want output of [ "1", "2", "3", "'word one'" ]
"1 2 3 \"word one\"".split(' ') // want output of [ "1", "2", "3", "\"word one\"" ]
I want output of [ "1", "2", "3", "'word one'" ]
instead of [ "1", "2", "3", "'word", "one'" ]
(i.e. I want to ignore spaces if they are in strings).