From: Logan Capaldo Date: 2005-02-18T08:17:23+09:00 Subject: Re: Regular expression question? On Fri, 18 Feb 2005 08:09:51 +0900, 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? > > Thanks in advance. > > Lei > > Like so: captures = string.scan(/company=(.+)/) There will be an extra level of nesting so you may (or may not, depending on how many groups your capturing) want to #flatten captures.