Posted By

ryanfiorini on 03/31/12


Tagged

email validator


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

rcraven


Email Validator


 / Published in: C#
 

A simple utility method to validate an Inputted Email Address.

  1. public static bool IsValidEmail(string email)
  2. {
  3. string pattern = @"^(([^<>()[\]\\.,;:\s@\""]+"
  4. + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
  5. + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
  6. + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
  7. + @"[a-zA-Z]{2,}))$";
  8. Regex regex = new Regex(pattern);
  9. return regex.IsMatch(email);
  10. }

Report this snippet  

You need to login to post a comment.