I need help splitting a string in javascript by space (" "), ignoring space inside quotes expression.
I have this string:
var str = 'Time:"Last 7 Days" Time:"Last 30 Days"';
I would expect my string to be split to 2:
['Time:"Last 7 Days"', 'Time:"Last 30 Days"']
but my code splits to 4:
['Time:', '"Last 7 Days"', 'Time:', '"Last 30 Days"']
this is my code:
str.match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
Thanks!