JSFiddle - React, Tailwind, and code Playground
JavaScript
var msg = '-m "this is a message" --echo "another message" test arg';
result = [];
msg.split("\"").map(function(v, i ,a){
if(i % 2 == 0) {
result = result.concat(v.split(" ").filter(function(v){
return v !== "";
}));
} else {
result.push(v);
}
});
console.log(result);