Solved

Regex - email

Posted on 2013-11-15
8
4,052 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
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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 19

Assisted Solution

by:bevhost
bevhost earned 125 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 125 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 125 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 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now