From: phlip Date: 2008-07-13T05:56:16+09:00 Subject: Re: regular expressions help > str = 'hi hello "hello world" hey yo' > p str.scan(/(".*")|(\w+)/).flatten.compact > > => ["hi", "hello", "hello world", "hey", "yo"] > > Greedy matching to the rescue! Also, non-capturing groups help us remove the .flatten.compact nonsense: p str.scan(/(?:".*")|(?:\w+)/) => ["hi", "hello", "\"hello world\"", "hey", "yo"] I'm not sure why one version capture the "" marks and the other did not...