Please check this out:
(?=^.{8,}$)
This part means has 8 more more characters, and the match starts at the start of input.
((?=.*\d)
Means contains a digit.
|(?=.*\W+))
Or contains something that is neither a letter or a digit
(?![.\n])
not starting with a dot or UNIX newline.
(?=.*[A-Z])
Contains at least one capital letter.
(?=.*[a-z])
Contains at least one lowercase letter
.*$
Consists entirely of non-newline characters and the matched group will contain the entire string.
Also check some threads:
Form validating![
^]
Here[
^]
Here[
^]
and
Here[
^]