I want to split a string, any string, into an array by spaces, preferably with the split()
method. However, I wish to ignore spaces in quotation marks.
Take, for example:
'word "words in double quotes"'
It should become an array with:
[
'word',
'words in double quotes'
]
I looked at similar answers to this, and they usually gave an array with:
[
'word',
'"words in double quotes"'
]
and that isn't what I'm looking for. I don't want the quotation marks added into the array element.
What regular expression could I use?