Skip to content

Instantly share code, notes, and snippets.

@sbstp
Created May 29, 2014 17:57
Show Gist options
  • Save sbstp/38933ac77fa13205cc60 to your computer and use it in GitHub Desktop.
Save sbstp/38933ac77fa13205cc60 to your computer and use it in GitHub Desktop.
var re = /([^\s"']+)|"([^"]*)"/g;
var match;
var parts = [];
while (match = re.exec(text)) {
parts.push(match[1] || match[2]);
}
console.log(parts);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment