From: Robert Klemme Date: 2011-01-20T22:19:42+09:00 Subject: Re: A tad of meta-programming needed On Mon, Jan 17, 2011 at 9:40 PM, RichardOnRails wrote: > Do you have a working example with symbols you could provide me?  And > what version of Ruby ran it? Basically you need a mapping from symbols to group indexes to make named groups work in 1.8. There are several ways you can do that 1. manual names = [:foo, :bar, :baz] ... md = rx.match str puts md[names.index(:foo) + 1] 2. semi automatic names = [:foo, :bar, :baz] def names.get(md, name) md[names.index(:foo) + 1] end ... md = rx.match str puts names.get(md, :foo) 3. or even class MatchData attr_accessor :names def get(name) self[names.index(name) + 1] end end ... md = rx.match str md.names = names puts md.get(:foo) Further variants are possible. But I'd switch to 1.9 soon - because it's faster and has a better regexp engine with named captures. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/