> 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, this is not a real answer, but here's on kind of workaround: ruby -v -e' "abc".gsub!(/\w/) {|m| p m }' ruby 1.6.2 (2000-10-16) [i686-linux] "a" "b" "c" The problem with this is that 1) string is passed to the block, not MatchData as you wanted ruby -e'str="abc"; str.gsub!(/\w/) {|m| p m.type }; p str' String String String "" 2) For some (probably quite simple) reason (I'm just too tired to find out) it does not work nice when using character class: ruby -e'str="abc"; str.gsub!(/[aeiou]/) {|m| p m; m.upcase }; p str' "a" "Abc" - Aleksi