From: Zach Dennis Date: 2005-02-18T09:12:55+09:00 Subject: Re: Regular expression question? Zach Dennis wrote: > Lei Wu wrote: > >> Hi, >> >> I want to translate the following Perl code into Ruby: >> >> @captures = ($text =~ /company=(.+)/g) >> >> Basically, the Perl version uses the g modifier to capture all >> occurrence of the matches in () and put them into an array. >> >> How do I do this in Ruby? I think I misunderstood the question, but after rereading Jame's and Bertram's post I think I see what Lei Wu was looking for. Zach > > > match_data = text.match( /company=(.+)/ ) # see [0] > > You can then treat your MatchData [1] object like an array and access > matches like: > > match_data[0] > > HTH, > > Zach > > [0] - http://www.ruby-doc.org/core/classes/String.html#M001335 > [1] - http://www.ruby-doc.org/core/classes/MatchData.html > > >