From: Robert Dober Date: 2008-04-02T23:27:34+09:00 Subject: Re: Regexp Capture Access On Wed, Apr 2, 2008 at 3:20 PM, Oliver Saunders wrote: > Given that: > > %r{(\w,)+}.match('a,b,c')[0] #=> "a,b," > > and > > %r{(\w,)+}.match('a,b,c')[1] #=> "b," > > How do I access the capture that contains "a,"? > -- > Posted via http://www.ruby-forum.com/. > > Use scan "a,b,c".scan(/\w+,/) --> ['a,', 'b,'] and in order to have the whole match you have to join the result of scan again. HTH Robert -- http://ruby-smalltalk.blogspot.com/ --- Whereof one cannot speak, thereof one must be silent. Ludwig Wittgenstein