From: Raimon Fs Date: 2009-04-07T03:38:42+09:00 Subject: Re: getting the results of a simple regex Robert Klemme wrote: > On 06.04.2009 19:12, Raimon Fs wrote: >> >>>> $2 >> want ... >> >> I also tried the Regexp.last_match but I'm getting the same, only the >> first value ... >> >> what I'm doing wrong ? > > You do not use String#scan. :-) => var="18,04 2,89 20,93 2,71 18,22" >> a=var.scan(/\d+,\d{2}/) => ["18,04", "2,89", "20,93", "2,71", "18,22"] >> a[0] => "18,04" >> a[1] => "2,89" >> a[2] => "20,93" >> a[3] => "2,71" >> a[4] => "18,22" :-) thanks .... > > Btw, you do not need the grouping as you want the complete match anyway. I was grouping with () because I was using: line =~ %r{(\d+,\d{2})(\s)(\d+,\d{2})(\s)(\d+,\d{2})(\s)(\d+,\d{2})(\s)(\d+,\d{2})} and then $1, $2, $3, $4, ... thanks for your help! regards, r. -- Posted via http://www.ruby-forum.com/.