Ruby Email validation with regex

前端 未结 9 914
有刺的猬
有刺的猬 2020-12-03 00:21

I have a large list of emails I am running through. A lot of the emails have typos. I am trying to build a string that will check valid emails.

this is what I have

9条回答
  •  生来不讨喜
    2020-12-03 01:11

    This one is more short and safe:

    /\A[^@\s]+@[^@\s]+\z/
    

    The regular is used in Devise gem. But it has some vulnerabilities for these values:

      ".....@a....",
      "david.gilbertson@SOME+THING-ODD!!.com",
      "a.b@example,com",
      "a.b@example,co.de"
    

    I prefer to use regexp from the ruby library URI::MailTo::EMAIL_REGEXP

    There is a gem for email validations

    Email Validator

提交回复
热议问题