Regular expression for validating email in c
Making it more restrictive than that can often be a risk of invalidating some valid e-mails. :[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f] | \[\x01-\x09\x0b\x0c\x0e-\x7f])*") @ (? You'd be surprised at some examples of valid e-mail addresses. Here’s a fairly common code sample from Rails Applications with some sort of authentication system: If you’re experienced at Regex, this seems simple. Sections 3.2.4 and 3.4.1 of the RFC go into the requirements on how an email address needs to be formatted and, well, there’s not much you can’t do in your email address when quotes or backslashes are involved.
NET Framework to find a badly formatted email address.As @Simon pointed out, your regular expression might consider some valid addresses as invalid. Per this source which I've found somewhere on this Stack Overflow page, this would be RFC5322-compliant: (? I think it’s a bit of an overkill for most use cases.Taken from Paul Warren’s page on the RFC822 Perl module: I generally avoid this sort of coding, but it will work in a pinch.