From: 7stud -- Date: 2008-02-06T14:30:47+09:00 Subject: Re: Regexp matching in a block of code Lovell Mcilwain wrote: > addresses = ["f...@bar1.com", "f...@bar2.com", "f...@bar3.com"] > competitors = ["bar.com", "bar1.com", "bar4.com"] > addresses.each do |add| > competitors.each do |comp| > puts "Checking Competitor: #{comp}" > if(add =~ Regexp.escape(comp)) > puts "matched" > else > puts "No Match" > end > end > end Try this: add = "f@bar.com" comp = "bar.com" if add =~ comp puts 'matched' else puts 'no match' end -- Posted via http://www.ruby-forum.com/.