Archives

All posts for the year 2011

This function check is value a valid email address:

public static bool IsEmailAddress(string email)
{   
   if(!email.Contains("@")) return false;
   string pattern = @"^(([^<>()[\]\\.,;:\s@\""]+"
                            + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
                            + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
                            + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
                            + @"[a-zA-Z]{2,}))$";
   
   Regex emailregex = new Regex(pattern);
   return emailregex.IsMatch(email);
}