On Sun, Apr 3, 2011 at 3:32 PM, Simon Harrison <simon / simonharrison.net> wrote: > Can anyone help with this? I thought grep would find any element that > matches in an array. It seems not... > > > irb(main):028:0> test = [['one', 'vol1'], ['one', 'vol2'], ['two', > 'vol3']] > => [["one", "vol1"], ["one", "vol2"], ["two", "vol3"]] > irb(main):029:0> test.grep(/one/) > => [] test.each {|x| puts x.grep /one/} => one one If you want to choose all pairs that match: result = [] test.each {|x| result << x unless x.grep(/one/).empty?} result => [["one", "vol1"],["one","vol2"]] Jesus.