From: Gavin Kistner Date: 2006-12-21T04:32:30+09:00 Subject: Re: Grabbing quoted substrings From: mitchell > > OK, I give up, what's the elegant method to > > grab the quoted substrings in the following, > > > > a = 'variables="x", "y", "z", "rho", "u", "v", "w", > "p/pinf", "s", "mach"' > > > > I want an array like, > > > > ["x", "y", "z", ..., "mach"] > > > > a.scan(/"([^"]+)"/).flatten No need to use flatten if you don't use the (unnecessary) grouping: a.scan( /"[^"]+"/ ) or a.scan( /".+?"/ ) (Both, of course, assuming no escaped backslashes in the content. It's not hard to come up with a regexp that accepts those, though at some point perhaps Ara's eval solution is easier.)