Skip to content

Instantly share code, notes, and snippets.

@mikeobrien
Created April 15, 2015 16:00
Show Gist options
  • Save mikeobrien/fd722540cf95e2c92308 to your computer and use it in GitHub Desktop.
Save mikeobrien/fd722540cf95e2c92308 to your computer and use it in GitHub Desktop.
public static class EmailAddressValidator
{
public const string EmailAddressRegex = "^[^@]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$";
private static readonly Regex Validator = new Regex(EmailAddressRegex);
public static bool IsValid(string email)
{
return email != null && !email.Contains("\n") && Validator.Match(email).Success;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment