You need to put the lookaheads after ^ and put [a-zA-Z] right after them and quantify the rest with {8,}:
^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])[a-zA-Z][a-zA-Z0-9]{8,}$
Regex that starts with letter, contains 1 uppercase/lowercase letter, one number and special characters & min 8 characters
^(?=.*[0-9])(?=.*[!@#$%^&*])[0-9a-zA-Z!@#$%^&*0-9]{8,}$
See the regex demo.
https://regex101.com/r/fGk1AC/1
> Pattern details:
-
^- start of a string -
(?=.*?[a-z])- at least 1 lowercase ASCII letter -
(?=.*?[A-Z])- at least 1 uppercase ASCII letter -
(?=.*?[0-9])- at least 1 ASCII digit 5.[a-zA-Z]- an ASCII letter -
[a-zA-Z0-9]{7,}- 7 or more ASCII letters or digits (\w also allows _) -
$- end of string.
Top comments (0)