var str = 'word" big phrase " word "big phrase"', words = []; str.replace(/"\s*([^"]*?)\s*"|[^\s"]+/g, function(word, phrase) { words.push(phrase || word); }); alert(words.join('\n'));