Solved

Regex - email

Posted on 2013-11-15
8
3,964 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
Comment Utility
fred&barney@stonehenge.com
is a valid email address that is not recognized by the above pattern
0
 

Author Comment

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

Expert Comment

by:bevhost
Comment Utility
^([\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
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 19

Assisted Solution

by:bevhost
bevhost earned 125 total points
Comment Utility
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 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 125 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

11 Experts available now in Live!

Get 1:1 Help Now