So I am trying to match email to email domains (ie bob@test to @test.com). Both the array of emails and email domains are in separate arrays. Right now I am trying the following
@domains = ["hotmail.com", "gmail.com"] @emails = ["blah@hotmail.com", "you@yahoo.com", "me@gmail.com"] @a = [] @domains.each {|d| @a << @emails.select{ |e| e=~ /#{d}/ } } @a.flatten! #=> ["blah@hotmail.com", "me@gmail.com"]
Now I can do stuff with @a
@a