In article <87hdweuzit.fsf / serein.a02.aist.go.jp>, Tanaka Akira <akr / m17n.org> writes: >> str.gsub!(/(\s\w)(\w+)(\w\s)/) do |m| >> m[3] + m[2] + m[1] >> end > > I think a regexp with named capture should binds local variables. > It makes possible to describe your example as follows. > > str.gsub!(/(?<a>\s\w)(?<b>\w+)(?<c>\w\s)/) { a + b + c } Oops. It should be: str.gsub!(/(?<a>\s\w)(?<b>\w+)(?<c>\w\s)/) { c + b + a } -- Tanaka Akira