V
Vell
I am trying to create a script that will allow me to compare email
addresses with a list of domains to see if they match. If they don't
match then everything is good to go, but if they do match, I want to
be able to delete them or move them out of the list.
The code that I wrote gives the following when its ran:
TypeError: type mismatch: String given
method =~ in untitled document at line 7
at top level in untitled document at line 7
method each in untitled document at line 5
at top level in untitled document at line 5
method each in untitled document at line 4
at top level in untitled document at line 4
Program exited.
I know my issue is with this particular line: if(add =~
Regexp.escape(comp))
But I am not sure where to find out or how to resolve it
Any help again is appreciated.
Code:
addresses = ["(e-mail address removed)", "(e-mail address removed)", "(e-mail address removed)"]
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 "#{check} matched"
else
puts "No Match"
end
end
end
addresses with a list of domains to see if they match. If they don't
match then everything is good to go, but if they do match, I want to
be able to delete them or move them out of the list.
The code that I wrote gives the following when its ran:
TypeError: type mismatch: String given
method =~ in untitled document at line 7
at top level in untitled document at line 7
method each in untitled document at line 5
at top level in untitled document at line 5
method each in untitled document at line 4
at top level in untitled document at line 4
Program exited.
I know my issue is with this particular line: if(add =~
Regexp.escape(comp))
But I am not sure where to find out or how to resolve it
Any help again is appreciated.
Code:
addresses = ["(e-mail address removed)", "(e-mail address removed)", "(e-mail address removed)"]
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 "#{check} matched"
else
puts "No Match"
end
end
end