From: Xavier Noria Date: 2007-03-16T23:14:59+09:00 Subject: Re: Splitting A String On Mar 16, 2007, at 2:35 PM, Andrew Stewart wrote: > Hello, > > What's a (good) way to convert this: > > 'a quick "brown fox" jumped "over the lazy" dog' > > into this: > > [ 'a', 'quick', 'brown fox', 'jumped', 'over the lazy', 'dog' ] Can quotes be escaped? If not there's a simple regexp that does the job: str = 'a quick "brown fox" jumped "over the lazy" dog' puts str.scan(/"([^"]*)"|(\w+)/).flatten.select {|s| s} You can also handle slashes, but it gets uglier. -- fxn