From: deal bitte Date: 2012-07-19T20:29:10+09:00 Subject: Re: Is there some seach algorithm available The excel_value is a variable . It can contain 1 or 2 or 3 or 4 words too Jan E. wrote in post #1069310: > Hi, > > So you're looking for the name with "deal" or "bitte" in it? > > Then you could do something like > > person_list.each do |name| > return name if name.split.any? do |name_part| > ['deal', 'bitte'].any? {|keyword| name_part.casecmp(keyword) == 0} > end > nil > end > > This will split the name on spaces and check if any part is "deal" or > "bitte", ignoring the letter case. If there's any match, this name is > returned. If no name matches, nil is returned instead (you may also use > person_list.first or so). -- Posted via http://www.ruby-forum.com/.