Answers for "split whitespace except in quotes javascript"

0

split whitespace except in quotes 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
Posted by: Guest on October-21-2020

Code answers related to "split whitespace except in quotes javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language