Please fix your broken email regex!
No, please don't use this so-called "regex email validation".
I can think of a few email addresses that are perfectly valid that do not match that regex. When you want to validate an email address, please do not use a hand-rolled (or even copy-n-pasted) regex.
Instead, use (Dart) https://pub.dev/packages/email_validator (or Perl) https://metacpan.org/pod/Mail::RFC822::Address, which properly implements the RFC822 (et. seq.) address according to the rules in the RFC.
(Jokingly...) Or, cut-n-paste this one (and only this one): http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html. Don't forget to remove the newlines from that 1400-char monster. :)
Hi @RandalSchwartz,
Sorry for the late answer and thanks for your advice. I will take a closer look at your proposition. I will let you know when it is included in future releases.
Best regards
Hi @RandalSchwartz,
could you give some examples of valid emails that do not match the current regex implementations (just to create some unit tests)
Thanks best regards
@joanpablo I think the list could be taken from here https://github.com/fredeil/email-validator.dart/blob/master/test/email_validator_test.dart#L6
https://regex101.com/r/HN6jk7/1
Thanks @vasilich6107 I will take a look
Any update on this ? I think it's a valid concern. I would rather depend on a single lib that validates email without regexp and with a pretty extensive test suite than an obscure regexp string copy pasted from who knows where.
Validating domain names and Email Addresses has always been a tricky issue since time immemorial. I have discussed the issues surrounding the same in a blog. If interested, please do check out. What is the ultimate goal of the Domain Name and Email ID Validation?
Hi I am on Angular
And using the below regex:
'^[a-z0-9]+([._-]?[a-z0-9]+)+@[a-z0-9]+([._-]?[a-z0-9]+)+\\.[a-z]{2,3}$'
But its not fulfilling my requirement, my requirement is below:
saa5@me-d_d_u.co
please anyone tell me, why this regex is not working for my above mentioned case.
Regards Babar Ali Shah
This is not stackoverflow, spamming your problems in unrelated issues will get you blocked.
Hi and thanks for highlighting the need for a new email validation approach. I believe you are right and we need a new implementation that doesn't use Regex. I will start working on this as soon as possible. Any PR is also weel received.
Thanks
I gave you the solution already. Use package:email_validator. Done.
Just check for the existence of @. https://mdswanson.com/blog/2013/10/14/how-not-to-validate-email-addresses.html After 10 years still valid.