How can I construct a regular expression such that a password field I am making contains at least one number, at least one lowercase letter and at least one uppercase letter where order DOES NOT matter and anything can be in-between these characters?
I have tried this and got something similar: ".*\\d.*[a-z].*[A-Z].*"
but that requires that the number comes first, the lowercase second and the uppercase last.
Yours is not one of the use case regular expressions are particularly good at – if you’re stuck with regular expressions, I guess you have no choice but to enumerate the 6 cases:
Check with actual java code would be easier (and more readable):
or (uglier, but possibly faster):