From: Dave Thomas Date: 2000-11-10T07:21:49+09:00 Subject: [ruby-talk:6229] Re: MatchData#[](0) hal9000@hypermetrics.com writes: > str.gsub(/aeiou]/) { $&.upcase } > > But suppose you didn't want to use $&, butt wanted to use a > MatchData object md and reference md[0]. Well.. you can use the fact that $~ is set the the last MatchData generated (which is the same as MatchData::last_match): "encyclopedia".gsub(/[aeiouy]/) { $~[0].upcase } # => "EncYclOpEdIA" Regards Dave