Last active
August 25, 2016 13:36
-
-
Save denpalrius/c6b17331cf35b1bd4e70e530af730bc3 to your computer and use it in GitHub Desktop.
C# Snippet to validate email addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class EmailValidator | |
{ | |
public static bool Validate(string email) | |
{ | |
try | |
{ | |
return new Regex(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$").IsMatch(email); | |
} | |
catch (Exception ex) | |
{ | |
string error = ex.Message; | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment