Avatar of johnson1
johnson1
 asked on

check for valid email

Hello,
Can you please help me find regex that I can use to check for valid email?
Greetings,
Skúli
Regular ExpressionsC.NET Programming

Avatar of undefined
Last Comment
Frank Helk

8/22/2022 - Mon
Ryan Chong

as a start, try look for:
http://regexr.com/3bcrb

you can go to Community tab and search for other available email regular expressions.

or you can try this:
http://www.regular-expressions.info/email.html
Dr. Klahn

There's no one regular expression that can detect whether any given email is valid.  There are too many possible forms and too many possibilities.

Example 1:  Non-ASCII domain names will cause simple regular expressions to fail.  [A-Za-z0-9] is not enough to contain all the possibilities of Chinese or Middle Eastern sites.

Example 2:  It's perfectly valid for an email address to be of the form xyz@alpha.beta.gamma.delta.epsilon.somewhere.com, which "violates" the common "a@b.c.com" format.

Example 3:  There are non-standard exceptions to the general "a@b.c.com" format.  Consider exex!research!ucbvax!user@ketch-ai, a valid uucp address.

In the final analysis, the only way to know if an email address is valid is to send to that address.
johnson1

ASKER
What would be a minimum check?
 How can I check if it contains
name (1)   - john
@ (2)  
(3)domain -   yahoo.com
and check if @ comes between the name and the domain, but not like yahoo.com@john
Your help has saved me hundreds of hours of internet surfing.
fblack61
Dave Baldwin

I use the format of 'a@b.c'.  There are no single letter user names or domain names that I know of.  I did run into one user with a 2 letter user name.  I don't use Regex though.

1. split the name at @.  If there is no @, it is not valid.
2. the first part before the '@' must be greater than 1 character.  It can contain '.'.
3. split the second part after the '@' on '.'.
4. each part of the second part must be greater than 1 character.  There are some TLDs like 'tv' that are only 2 letters.
SOLUTION
skullnobrains

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
kaufmed

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
skullnobrains

it lacks support for stuff like "foo bar"@mydomain.com
anyway, given the fact the author has been gone for 2 months without feedback...
ASKER CERTIFIED SOLUTION
Frank Helk

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
johnson1

ASKER
Thank you very much for your help. Sorry for late reply.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Frank Helk

If your question is answered, please assign points and close it.