I need a regular expression in Java with the following requirements:
I have tried several expressions that don't work - this is the best so far:
(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).*
Anchor your regex, and don't use .
which allows anything:
^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]*$
^$
matches beginning and end of string, [a-zA-Z0-9]*
makes sure the characters are only those in the character class.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.