split whitespace except in quotes javascript

JavaScript
// Hard to read, but works
// If you want to keep the \ in the string, replace the: c.replace(/\\(.)/,"$1"); by: c;

keywords.match(/\\?.|^$/g).reduce((p, c) => {
        if(c === '"'){
            p.quote ^= 1;
        }else if(!p.quote && c === ' '){
            p.a.push('');
        }else{
            p.a[p.a.length-1] += c.replace(/\\(.)/,"$1");
        }
        return  p;
    }, {a: ['']}).a

Source

Also in JavaScript: