I'm using the following regex to validate emails in an email DB of a Rails App:
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
it kinda works, but it leaves me with invalid mails wich have this kind of errors:
name@domain..com
How can I rwrite this regex to avoid that or wich is the best regex to clean up an email list I have to leave only valid email addresses? I'm using a method like this one to clean up the list:
def mailSweep
  mails = Email.all.lazy
  for address in mails do
    if address.email.to_s =~ /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
      puts address.email.to_s + " " + "it's valid"
    else
      puts address.email.to_s + " " + "it's invalid, destroying..."
      address.destroy
    end
  end
end
 
     
    