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

x
?
Solved

Regex - email

Posted on 2013-11-15
8
Medium Priority
?
4,303 Views
Last Modified: 2013-11-18
This is the email pattern I use to valid email address format.  I just want to add "`"  to this pattern. Sample john'ona.doe@mysite.com This is a good format.
^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$
0
Comment
Question by:VBdotnet2005
[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
8 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 39652176
fred&barney@stonehenge.com
is a valid email address that is not recognized by the above pattern
0
 

Author Comment

by:VBdotnet2005
ID: 39652219
If that is the case, could you add that also?
0
 
LVL 19

Expert Comment

by:bevhost
ID: 39652317
^([\w\d\-\.\`\&]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 14

Expert Comment

by:sentner
ID: 39652344
To add characters to the name portion, just add them inside the first set of square brackets. There are a bunch of possible characters missing from the pattern above (including: ! # $ % & ' * + - / = ?  ^ _ ` . { | } ~), please see:

http://tools.ietf.org/html/rfc3696

That said, your expression does include some unnecessary redundancies (like "\w\d" which can be simplified to just \w).   You may need to escape out some of the special characters (possibly including `) but not all of them.
0
 
LVL 19

Assisted Solution

by:bevhost
bevhost earned 500 total points
ID: 39652362
You're still a long way from accepting all valid email addresses.
see
http://en.wikipedia.org/wiki/Email_address
Also I think ' is probably more common than `
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 500 total points
ID: 39652363
You might want to read the information presented at this link:

http://www.regular-expressions.info/email.html

...pertaining to why overly-complicated email patterns aren't usually necessary.
0
 
LVL 14

Accepted Solution

by:
sentner earned 500 total points
ID: 39652393
This should catch all of the possible characters:

^([\w!#$%&\'\*+-/=\?^\`\.\{\|\}~]+)\@{1}(([\w-]{1,67})|([\w-]+\.[\w-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$
0
 
LVL 11

Assisted Solution

by:SAMIR BHOGAYTA
SAMIR BHOGAYTA earned 500 total points
ID: 39655778
hi.. You just use this...

private static Regex emailRegex = new Regex(@"^([a-zA-Z0-9\'_\-\.]+)@((\[[0-9]{1,3}" +
         @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
         @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
0

Featured Post

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.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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