From: James Edward Gray II Date: 2006-02-27T22:42:44+09:00 Subject: Re: string contains one of these??? On Feb 27, 2006, at 7:35 AM, mikkel wrote: > Imagine, > > I have > > leagues=%w{ 1D 2D U16 U19 LR RR JNL NL} > > for a given string, say "some stuff NL is chunky" i want determine > which > of the matches it contains... > > now, the hard way (more code, less thought) would be to iterate the > array and do a ~= on it...but is there a simpler way ??? The hard way isn't too hard and doesn't require but a line of code: >> leagues=%w{ 1D 2D U16 U19 LR RR JNL NL} => ["1D", "2D", "U16", "U19", "LR", "RR", "JNL", "NL"] >> str="some stuff NL is chunky" => "some stuff NL is chunky" >> leagues.find_all { |league| str.include? league } => ["NL"] Hope that helps. James Edward Gray II