From: Robert Klemme Date: 2012-02-06T17:20:36+09:00 Subject: Re: How to keep list of reglar expressions into array On Mon, Feb 6, 2012 at 7:13 AM, Lucky Nl wrote: > I have morethan one regular expressions > I want to keep all in array and iterate them to check my input matched > or not > > reg1 =  /ruby:\s*$/i > reg2 =  /rails:\s*$/i In this case it's easier to use one regexp: /r(?:uby|ails):\s*$/i > input1 = "ruby is my favorite language" > > i want to iterate regexp's array and check where input1 matching.But the > porblem is not the porper way getting regexp in loop .It's returning > string type Please show the code and the error. You can do if regexps.any? {|rx| rx =~ s} puts "any matched" end r = regexps.find {|rx| rx =~ s} and puts "#{r} matched" puts "#{regexps.select {|rx| rx =~ s}} all matched" Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/