Skip to content

Instantly share code, notes, and snippets.

@rowej83
Last active August 29, 2015 13:56
Show Gist options
  • Save rowej83/9203246 to your computer and use it in GitHub Desktop.
Save rowej83/9203246 to your computer and use it in GitHub Desktop.
c# - returns true boolean if valid email address, not case sensitive
public bool checkIfEmail(string checkString){
string regex=@"^(?("")(""[^""]+?""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,24}))$";
return Regex.IsMatch(checkString,regex,RegexOptions.IgnoreCase);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment