From: Kent Dahl Date: 2002-03-18T22:24:08+09:00 Subject: Re: looping an array Bob wrote: > I would like to put the keywords into an array outside the loop as it > is easier see. Something like "kw = ["jabberwock","jubjub"] and then > doing the same thing as the original script (as far as the printing to > console and a file). This might help you on your way: data = [ "Oh my dear JabberWock, ", "won't you jubjub", "my JubJub?", "juicy-fruit", "fartislab" ] keywords = ["jabberwock", "jubjub" ] regexps = keywords.collect{|kw| Regexp.new(kw, Regexp::IGNORECASE ) } data.each{|line| regexps.each{|r| if r =~ line then puts line break end } } -- <[ Kent Dahl ]>================<[ http://www.stud.ntnu.no/~kentda/ ]> )__(stud.techn.; ind. econ & management: computer technology)__( /"Opinions expressed are mine and not those of my Employer, "\ ( "the University, my girlfriend, stray cats, banana fruitflies, " ) \"nor the frontal lobe of my left cerebral hemisphere. "/