From: David Alan Black Date: 2002-04-26T19:52:48+09:00 Subject: Re: Parsing Repeating Regexp Matches Hello -- On Fri, 26 Apr 2002, Curt Sampson wrote: > On Fri, 26 Apr 2002, Michael Brailsford wrote: > > > > "{foo} {bar} {something else} {and so on}" > > > > > > And I want to parse it into an array that looks like this: > > > > > > ["foo", "bar", "something else", "and so on"] > > > > Try String#scan. It is similar to te g options in sed/vim/perl's s///, > > and the return from String#scan is an Array. > > Ah, that's it. So I want > > parsed_defs = defs.scan(/\{([^}]+)} ?/).collect { |m| m[0] } You can just .flatten the resulting array of arrays: parsed_defs = defs.scan(/\{(.*?)\}/).flatten Tossing in another possible way to do the regex, just for fun :-) Also, you could possibly avoid the need to flatten if you did something like: s.scan(/[^{}]+(?=\})/) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav