Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Regular Expression that supports foreign email address characters

Posted on 2014-01-08
8
Medium Priority
?
927 Views
Last Modified: 2014-01-18
The regular expression I use for email address validation is

\w+([-+!$%&*/=?{|}.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

which I think is pretty standard but it doesn't support foreign characters such as

Ébaker@mydemo.com

Can anyone recommend a better expression?

Note I have come across this:
http://stackoverflow.com/questions/16454939/regex-to-validate-international-email

which seems to suggest using
[^\s@]+@[^\s@]+\.[^\s@]+

which appears more flexible but apparently does allow for example test@hello..com

Can someone tell me what the above expression is actually doing?

I know there is also this http://ex-parrot.com/~pdw/Mail-RFC822-Address.html which obviously seems like overkill (and interestingly doesn't seem to allow some of the foreign character examples the above expression does).

Also I'm using .net which may impact this as some of the "regex" testing sites seemed to think my original regex expression did actually allow my foreign example email address, but my ,net aspx page certainly doesn't allow it.
0
Comment
Question by:purplesoup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 34

Expert Comment

by:Big Monty
ID: 39766161
If all you want to match is letters (including "international" letters) you can use \p{L}
0
 

Author Comment

by:purplesoup
ID: 39767694
You mean this?

Doesn't seem to work - doesn't even validate standard email addresses

\p{L}+([-+!$%&*/=?{|}.']\p{L}+)*@\p{L}+([-.]\p{L}+)*\.\p{L}+([-.]\p{L}+)*
0
 
LVL 13

Expert Comment

by:Jitendra Patil
ID: 39767889
try the below link, may be of use to you.
How To Validate An Email Address
hope this helps.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:purplesoup
ID: 39768574
He seems to be suggesting this

^(?!\.)("([^"\r\\]|\\["\r\\])*"|([-a-z0-9!#$%&'*+/=?^_`{|}~] |(?@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$

Open in new window


but all the regex online testing sites I've tried it on say it isn't valid...
0
 
LVL 13

Expert Comment

by:Jitendra Patil
ID: 39770675
hi can you try some more from the below link
email address (RFC 2822 mailbox)
hope this helps.
0
 

Author Comment

by:purplesoup
ID: 39771077
Hmm - not really sure what to make of these suggestions - you've posted a link to a whole page of email validator expressions, none of which work with foreign email addresses. That's about 21 expressions that don't work.

I'm testing it here:
http://www.freeformatter.com/regex-tester.html
0
 

Accepted Solution

by:
purplesoup earned 0 total points
ID: 39776143
I went with this one in the end

[^\s@]+@[^\s@]+\.[^\s@]+
0
 

Author Closing Comment

by:purplesoup
ID: 39790432
I found the answer from searching in the end - I couldn't get any of the suggested solutions to actually work.
0

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question