Skip to content

Instantly share code, notes, and snippets.

@MilenPavlov
Created April 15, 2015 08:45
Show Gist options
  • Save MilenPavlov/fd89529b3e6224484a1b to your computer and use it in GitHub Desktop.
Save MilenPavlov/fd89529b3e6224484a1b to your computer and use it in GitHub Desktop.
email regex (rfc compliant)
email regex:
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
usage:
bool isEmail = Regex.IsMatch(emailString, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment