From: Ravil Bayramgalin Date: 2008-03-22T03:28:59+09:00 Subject: Re: A question involving variable evaluation Oh, i see. Then you can use Proc: string = 'foobar' patterns = [[/f(.*)(b.r)/, proc {|match| match[2] + match[1].upcase }]] p patterns.map {|regexp, block| block.call string.match(regexp) } 2008/3/21, mike leonard : > On Mar 21, 12:41 pm, Ravil Bayramgalin wrote: > > just store a needed match position for every pattern and then use it like that: > > > > string = 'foobar' > > patterns = [[/(oo)+(.*)/, 2], [/(.*)bar/, 1]] > > p patterns.map {|regexp, position| string[regexp, position] } > > > Well the idea is that users will be able to create new filters just by > appending items to the array. For example, if you wanted to convert > FOObar to fooBAR, you could do: > > patterns << [/(FOO)(bar)/, $~[0].downcase + $~[1].upcase] > > How would this work with your suggestion? > > -- http://digging-ruby.blogspot.com/