MrMistreater

Email validator

May 8th, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  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.    }
Advertisement
Add Comment
Please, Sign In to add comment