ako... wrote:
> hello,
> 
> 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 + '_' }

puts 'a-b-c-'.gsub(/(.)-/) { |str| str + '_' }

Though gsub never does give you access to MatchData.  MatchData is used
when you do something like this:

matchData = /([[:alpha:]]+):([[:alpha:]]+)/.match('abc:xyz')
	=> MatchData
matchData[1]
	=> 'abc'
matchData[2]
	=> 'xyz'

-- 
Neil Stevens - neil / hakubi.us

'A republic, if you can keep it.' -- Benjamin Franklin