From: Pau Garcia i Quiles Date: 2006-06-29T03:36:34+09:00 Subject: Re: grep-ing an array Quoting aidy : What about Array.assoc("mystring")? > Hi, > > I am trying to find whether specific strings are contained within a > array > > table_array contains these elements [["", "95424", "Joe Stalin", "Field > Sales", "80%", "27/06/06", "", "Amend"]] > > I am grep-ing whether the text I am looking for is in. So I have got an > array of regex > > reg_text = /Stalin/, /Field Sales/, /80%/ > > Now, if the grep finds the string pattern a full string will be > returned > if x.grep(y) == /Stalin/ > => ["Joe Stalin"] > > so, I have got another array > > real_text = ["Joe Stalin"], ["Field Sales"], ["80%"] > > this is the code > > $table_array.each{|x| > reg_text.each{|y| > real_text.each{|z| > if x.grep(y) == z then p "#{z} is in table" end > } > } > } > > But I think it is messy, and I wonder if there was a better way? > > Cheers > > aidy > > >