From: Brian Candler Date: 2007-03-18T19:23:06+09:00 Subject: Re: Splitting a String On Sun, Mar 18, 2007 at 01:34:07PM +0900, Bernard Kenik wrote: > ruby-talk-admin@ruby-lang.org wrote: > > > >------------------------------------------------------------------------ > > > >Subject: > >Re: Splitting A String > >From: > >Xavier Noria > >Date: > >Fri, 16 Mar 2007 23:21:17 +0900 > >To: > >ruby-talk@ruby-lang.org (ruby-talk ML) > > > >To: > >ruby-talk@ruby-lang.org (ruby-talk ML) > > > > > >On Mar 16, 2007, at 3:14 PM, Xavier Noria wrote: > > > >>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' ] > >> > From a newbie > > 'a quick "brown fox" jumped "over the lazy" dog'.gsub('"','').split(/ /) However that splits into individual words. If you look carefully at the example, the quoted strings "brown fox" and "over the lazy" need to end up in a *single* array element in the result. Regards, Brian.