Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail From: Simon Harrison Newsgroups: comp.lang.ruby Subject: Using grep on subarrays - help! Date: Sun, 3 Apr 2011 08:32:25 -0500 Organization: Service de news de lacave.net Lines: 24 Message-ID: NNTP-Posting-Host: bristol.highgroove.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: talisker.lacave.net 1301837643 28974 65.111.164.187 (3 Apr 2011 13:34:03 GMT) X-Complaints-To: abuse@lacave.net NNTP-Posting-Date: Sun, 3 Apr 2011 13:34:03 +0000 (UTC) X-Received-From: This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway X-Mail-Count: 380843 X-Ml-Name: ruby-talk X-Rubymirror: Yes X-Ruby-Talk: Xref: x330-a1.tempe.blueboxinc.net comp.lang.ruby:2196 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/) => [] irb(main):030:0> test.each.grep(/one/) => [] irb(main):031:0> test => [["one", "vol1"], ["one", "vol2"], ["two", "vol3"]] irb(main):032:0> test.grep('one') => [] irb(main):033:0> test2 = ['one', 'one', 'two', 'three'] => ["one", "one", "two", "three"] irb(main):034:0> test2.grep(/one/) => ["one", "one"] irb(main):035:0> -- Posted via http://www.ruby-forum.com/.