Some questions about regex

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.


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:


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?

Yes, inside the lookahead, not on the lookahead.

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

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.