JSFiddle - React, Tailwind, and code Playground
JavaScript
var regex = /"([^"]*)"|'([^']*)'|[^\s,]+/g;
var text = "Hello world \"Boston Red Sox\" hello, world, \'boston, red sox\', \'beached whale\', pickup sticks";
var output = [];
var m;
while ((m = regex.exec(text)) !== null)
{
output.push(m[1] || m[2] || m[0]);
}
console.log(output);