Please play with it here- https://dotnetfiddle.net/l EFYGJ var input = "[email protected]"; var has Number = new Regex(@"[0-9] "); var has Upper Char = new Regex(@"[A-Z] "); var has Minimum8Chars = new Regex(@"."); var is Validated = has Number. # match anything with previous condition checking # length at least 8 characters and also maximum of 8 ) # End of group if you plan to only force the password to have at least 1 digit, 1 any Unicode uppercase letter and be exactly 8 chars long (allowing any characters but a newline). A "big" (yes, I know there are bigger) regex like this is a nightmare to understand, maintain and tweak.I've taken regex from this source- Password must be 8 characters including 1 uppercase letter, 1 special character, alphanumeric characters Issue is that it returns 'True' always and the string that I am sending to method is not valid. If you also don't have any covering automatic tests it's just gonna end up being one of those Lo C that is "forbidden" for everyone to touch, because "it might break".( # Start of group (? =.*[A-Z]) # must contain at least one uppercase character (?Help me if I am doing something wrong with the regex. =.*\W) # must contain at least one special symbol .This requires the semicolon if it's not the end (because there are more than one address), but allows no semicolon if it's the end. If it doesn't work for you get sure to trim spaces at the beggining and end of the expression. It is also anchored so the entire input must match the pattern, which is helpful since you're validating input.
See Lookahead Example: Simple Password Validation if you ever have any doubt when using regex for password validation.
To avoid such vulnerability, you should validate text fields (such as names, addresses, tax identification numbers, and so on) and use regular expressions to do the following: Regular expression support is available to ASP. If you capture input by using server controls, you can use the Regular Expression Validator control to validate that input.
NET applications through the Regular Expression Validator control and the Regex class in the System. You can use regular expressions to restrict the range of valid characters, to strip unwanted characters, and to perform length and format checks.
This works perfectly fine, but only allows one e-mail to be entered.
Now I wanted to extend that and allow multiple mail-addresses to be added (just like MS Outlook, for example) with a semicolon as a mail-splitter.
You can constrain the input format by defining patterns that the input must match.