ako... wrote: > if i indeed want to start using MatchData instead of the "warts" such > as $-variables in regular expressions, how do i go about writing code > blocks for String#sub et al if i want to get a match for a particular > group? > > example: > > puts 'a-b-c-'.gsub(/(.)-/) { $1 + '_' } This is long, but will do: puts 'a-b-c-'.gsub(/(.)-/) { Regexp.last_match[1] + '_' } It would be very nice if .gsub started yielding the actual MatchData object in 2.0.