Link to home
Start Free TrialLog in
Avatar of MarcoCastro
MarcoCastroFlag for Brazil

asked on

A RegEx to e-mail

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
Avatar of kaufmed
kaufmed
Flag of United States of America image

Unless you need something specific, why not just look for "non-whitespace, @ symbol, non-whitespace"?
\S+@\S+

Open in new window

To make it a tad safer, you can exclude extra @'s:
[^\s@]+@[^\s@]+

Open in new window

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

ASKER CERTIFIED SOLUTION
Avatar of Steve813
Steve813
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial