I came across this example to see if a password has at least one lowercase, at least one uppercase, at least one digit, at least one special character and is at least 10 characters long.

``````(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\\$])[a-zA-Z0-9!@#\\$]{10,}
``````

I understand the `?=` is positive lookahead but adding the `.` means any character. What do they mean by any character? Does this mean any specific letter or digit or any character as in any location of the string given of the set [a-z].

Also, I thought the + meant 1 or more so why the * which means 0 or more?

Lastly, what would be the difference between the above example and this:

``````(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\\$]){10,}
``````

you can’t use a quantifier with a lookahead as a lookahead is 0-width, so you have always infinite characters of that length

the `.*` is needed because all lookaheads look from same position, and the searched character can be at any point in the string, so you can have any number of any character, and then the searched character.

What limits the possible characters is the last part, `[a-zA-Z0-9!@#\\$]{10,}`, this says that these are the possible characters and that there can be 10 or more

Except * is quantifier and it was used in the expression.

and what position would that be?

that depends on what is matched by the pattern - in this case they look from the position before `[a-zA-Z0-9!@#\\$]{10,}`