?
Solved

A RegEx to e-mail

Posted on 2011-05-11
4
Medium Priority
?
165 Views
Last Modified: 2012-05-11
Hi,

  What is the pattern tha handles these two e-mail:

  joe@gmail.com
  joe@gmail.com.br

  The patterns that I found don't handle the .br part of the string

  Thanks,

  Marco Castro
0
Comment
Question by:MarcoCastro
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35743576
Unless you need something specific, why not just look for "non-whitespace, @ symbol, non-whitespace"?
\S+@\S+

Open in new window

0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35743581
To make it a tad safer, you can exclude extra @'s:
[^\s@]+@[^\s@]+

Open in new window

0
 
LVL 4

Expert Comment

by:Sathish DV
ID: 35744017
Hope this will be useful....

string EmailPattern = @"^(([\w-]+\.)+[\w-]+|([a-zA-Z]{1}|[\w-]{2,}))@"
               + @"((([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\."
               + @"([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])\.([0-1]?[0-9]{1,2}|25[0-5]|2[0-4][0-9])){1}|"
               + @"([a-zA-Z]+[\w-]+\.)+[a-zA-Z]{2,4})$";

Open in new window

0
 
LVL 1

Accepted Solution

by:
Steve813 earned 2000 total points
ID: 35747460
here's another version
^([\w\-\.]+)@((\[([0-9]{1,3}\.){3}[0-9]{1,3}\])|(([\w\-]+\.)+)([a-zA-Z]{2,4}))$

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

755 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