From: Dan Doel Date: 2003-08-18T17:33:05+09:00 Subject: Re: Bug when rerouting String#gsub with a block using $1? What about: p "hello world".gsub(/(\w+)/) { puts $1; $1 } puts class String alias :old_gsub :gsub def gsub(*args, &block) if block pattern = args[0] old_gsub(pattern) { |match| eval "#{pattern.inspect} =~ \"#{match}\"", block yield match } else old_gsub(*args, &block) end end end p "hello world".gsub(/(\w+)/) { puts $1; $1 } Or does this miss something that gsub does? - Dan