amazing... thanks a bunch everybody... On Tuesday, February 28, 2006, at 2:53 AM, Robert Klemme wrote: >Christian Neukirchen wrote: >> "Robert Klemme" <shortcutter / googlemail.com> writes: >> >>> 2006/2/27, mikkel <mikkel / helenius.dk>: >>>> 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 ??? >>> >>>>> leagues=%w{ 1D 2D U16 U19 LR RR JNL NL} >>> => ["1D", "2D", "U16", "U19", "LR", "RR", "JNL", "NL"] >>>>> "some stuff NL is chunky".scan( Regexp.new( leagues.join('|') ) ) >>> => ["NL"] >> >> irb(main):002:0> "some stuff NL is chunky".scan >> Regexp.union(*leagues) => ["NL"] > >Even better! Didn't know about that method. Learn something new every >day. Thanks! > > robert > > Mikkel Bruun www.strongside.dk - Football Portal(DK) nflfeed.helenius.org - Football News(DK) ting.minline.dk - Buy Old Stuff!(DK) -- Posted with http://DevLists.com. Sign up and save your time!