From: daz Date: 2005-08-01T14:46:04+09:00 Subject: Re: Defining regexp's and variables set by them Garance A Drosehn wrote: > The thing is, by changing 'check' to '(check|test)', I have to > remember that the when clause also needs to change from > referencing $1 to referencing $2. Note that in this case I do > not *care* whether it matched 'check' as opposed to 'test'. > Either word is acceptable to me, so I do not need the actual > value of $1 for anything. Hi Garance, You can prevent the grouped expression from creating a back-reference by using the ?: extension ... s = 'start: check 41 is less than ...' re_simple = /check (\d+)/ s =~ re_simple p [$1, $2] #-> ["41", nil] re_simple = /(?:check|test) (\d+)/ s =~ re_simple p [$1, $2] #-> ["41", nil] HTH, daz