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