From: "Olivier D." Date: 2004-07-07T22:17:37+09:00 Subject: Re: Regexp exercise On 2004-07-07, Carlos wrote: > ["Olivier D." , 2004-07-07 14.37 CEST] >> What should I do? Is the $1 method *that* bad? (after all, I just use it >> inside the 'if' loop...) > > I don't find it bad, but if you want to avoid it you can do > > matchdata=/b: (\d+)/.match(string) and value=matchdata[1] > Thanks for the advice. It's just that it took me two days to remember that the groups of a pattern are put in $1..$9 with the =~ operator. I discovered that $1 can have two different values: - nil if a number is not found - the number found if it exists Which means: no errors possible from a previous match. $1 has his value changed every time. -- Olivier D.