Solved

Regex - email

Posted on 2013-11-15
8
4,198 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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

690 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