From: Chris Shea Date: 2009-10-28T23:30:08+09:00 Subject: Re: Regexp: rubular VS match. Why is the result different ? On Oct 28, 10:12 am, Ale Ds wrote: > I have to capture by means of regexp the content between '<' and '>' > > as instance: > > str = 'anystringanystringanystringanystring' > I need the array['hour','min,'sec'] > > I have written the regexp: /(<([^<>]+)>)+/ > and I have tested it in rubular.com site (It work !) > > I have run it in irb:>> /(<([^<>]+)>)+/.match('anystringanystringanystringanystring') > > => #" 1:"" 2:"hour"> > > As you can see match method return just the first match in MatchData obj > > Do you know why ? > > thank you, > Alessandro > -- > Posted viahttp://www.ruby-forum.com/. Alessandro, You'll want the String#scan method (http://www.ruby-doc.org/core/ classes/String.html#M000812). 015:0> regexp = /<([^<>]+)>/ => /<([^<>]+)>/ 016:0> str = 'anystringanystringanystringanystring' => "anystringanystringanystringanystring" 017:0> str.scan(regexp) => [["hour"], ["min"], ["sec"]] HTH, Chris