Validating email addresses using regular expressions Franch free sex chat
Unless you know something that they don't, use the solutions they've already built.My unittests mention, using your regex : FAIL src/js/utils/__tests__/Validation (0.186s) ● The Emailvalidator "is Valid EMail" › it should fail when it has no dot ● The Emailvalidator "is Valid EMail" › it should fail when top domain level has only one char ● The Emailvalidator "is Valid EMail" › it should fail when the local part starts or ends with a dot ● The Emailvalidator "is Valid EMail" › it should fail when it has two or more consecutive dots in the local part, Of course one char topdomain is not a syntax error (just pragmatic) but the other ones are. As to why it's not working for you, that's impossible to say since you haven't told us how you're using it.To that end, the spec provides this PCRE: along with a polyfill (if you have users with older browsers).Very smart people wrote the HTML5 spec, and very smart people wrote the browsers that implement it.
In this file they came up with a (very large) email validation regex that may be worth a look for you.What if I asked you to produce a regular expression to validate an email address?I disagree with rolfl's assertion that, "There is no practical way to validate an e-mail address by regex alone." He is correct—as illustrated by the somewhat infamous SO answer he linked to—that it's impractical to validate RFC-5322 …defines a syntax for e-mail addresses that is simultaneously too strict (before the '@' character), too vague (after the '@' character), and too lax (allowing comments, whitespace characters, and quoted strings in manners unfamiliar to most users) to be of practical use here...to mention that there are now literally thousands of TLDs.
But it's absolutely practical to come up with a very good compromise, which is exactly what the writers of the HTML5 spec did.