Created
April 12, 2018 07:36
-
-
Save secretorange/6f127998d5baafdf357cfdcf54a8b628 to your computer and use it in GitHub Desktop.
Commonly used RegEx for DotNet. Email, Password etc.
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 static class Constants | |
{ | |
public static class RegEx | |
{ | |
public const string Email = @"^[a-zA-Z0-9#'$%+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9#'$%+/=?^_`{|}~-]+)*[a-zA-Z0-9#'$%+/=?^_`{|}~-]*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9]{2,}$"; | |
// Passwords must be at least 8 characters and contain at 3 of 4 of the following: upper case (A-Z), lower case (a-z), number (0-9) and special character (e.g. !@#$%^&*) | |
public const string Password = "^((?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])|(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[^a-zA-Z0-9])|(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])|(?=.*?[a-z])(?=.*?[0-9])(?=.*?[^a-zA-Z0-9])).{8,}$"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment