Parsing delimiters such as quotes (or parens, brackets etc but especially quotes for a couple of reasons) is best done with a CFG parser, not regular expressions. But it's quite easy, and done in O(n) time which is the same as regular expressions, and better than the irregular expressions you might end up using for this sort of thing (REs are native though).
function parseStrings(str){
var parse=[], inString=false, escape=0, end=0
for(var c=0; c<str.length; c++) switch(str[c]){
case '\\': escape^=1; break
case ',': if(!inString){
parse.push(str.slice(end, c))
end=c+1
}
escape=0
break
case '"': if(!escape) inString=!inString
default: escape=0 // fallthrough from previous case
}
if(inString) throw SyntaxError('expected matching " at the end of the string')
if(end<c) parse.push(str.slice(end, c))
return parse
}
That can be extended to parse single quoted strings and other delimiters too (you'd have to build a stack for non-quote delimiters). I posted a modified version that handles both single and double quotes in Regex to pick commas outside of quotes