From: Bertram Scharpf Date: 2005-02-18T09:09:45+09:00 Subject: Re: Regular expression question? Hi, Am Freitag, 18. Feb 2005, 08:12:49 +0900 schrieb James Edward Gray II: > On Feb 17, 2005, at 5:09 PM, Lei Wu wrote: > > >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. > > captures = text.scan(/company=(.+)/) As far as I see, `+' is greedy. Further, you don't need the grouping. May this is better: captures = text.scan /company=\S+/ Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de