Looking for a regex - 8 char min w/ 1 num and 1 char
regex
Solution
something like
^(?=.*[0-9])(?=.*[a-zA-Z])\w{8,}$
would work
dissected:
- `^` the beginning of the string
- `(?=.*[0-9])` look ahead and make sure that there is at least 1 digit
- `(?=.*[a-zA-Z])` look ahead and make sure there is at least 1 letter
- `\w{8,}` actually match the 8+ characters
- `$` the end of the string
Edit: if you want extra characters (that don't count for the 1 letter requirement) use
^(?=.*[0-9])(?=.*[a-zA-Z]).{8,}$
this will allow for any character besides newline to be used
If you only want certain characters allowed, replace `\w` in the first regex with `[A-Za-z0-9@#$%^&*]` with your choice of symbols
^(?![0-9]$)(?![a-zA-Z_]$)\w{8,}$
Problem
I'm looking for some help creating a regex that requires 8 char (at a minimum) along w/ 1 number and 1 char (not special char). example: a1234567 is valid but 12345678 is not Any help for a regex newb? EDIT: Thanks for the quick replies- the implementation that worked in VB is shown below ``` Dim ValidPassword As Boolean = Regex.IsMatch(Password, "^(?=.*[0-9])(?=.*[a-zA-Z])\w{8,}$") ```