From: William James Date: 2006-02-23T04:48:31+09:00 Subject: Re: A regexp for an include? method Boucher, Eric wrote: > Hi, > > I want to see if a certain pattern is inside an array. I tried: > myArray.flatten.include?(/myPattern/) > > but it always return false. Why? Is it because the "include?" doesn't takes > regular expressions? > Here's another example that I tried inside an irb session: > > data = ["TC_TP1", "TC_TP2", "TC_TP3"] > =>["TC_TP1", "TC_TP2", "TC_TP3"] > data.include?(/TC_TP/) > => false > data.include?(/TC_TP.*/) > => false > data.include?(/TC_TP1/) > => false > data.include?("TC_TP1") > => true !!! > > Thanks for your help. myArray.flatten.grep(/myPattern/)