1// Hard to read, but works
2// If you want to keep the \ in the string, replace the: c.replace(/\\(.)/,"$1"); by: c;
3
4keywords.match(/\\?.|^$/g).reduce((p, c) => {
5 if(c === '"'){
6 p.quote ^= 1;
7 }else if(!p.quote && c === ' '){
8 p.a.push('');
9 }else{
10 p.a[p.a.length-1] += c.replace(/\\(.)/,"$1");
11 }
12 return p;
13 }, {a: ['']}).a
14