I'm trying to create a RegExp to match new passwords (which works), but I only need a last step to make it work 100%.
Here's the RegExp and what it is supossed to:
((?=.*(\\d|[\\(\\)\\{\\}\\?!\\$&\\*%\\=\\+_\\-\\.]))(?=.*[a-z])(?=.*[A-Z]).{8,})
The RegExp says that: Digits OR Symbols (){}?!$&%*=+-. must be used -and that's what doesn't work, the OR operator, as I can insert both numbers and symbols-, at least one lowercase, at least one uppercase and a minimum lenght of 8 characters.
I've tried to use the OR operator | in several ways, but I can't make it work.
What am I missing? Thank you very much in advance.
Note: I'm using this regular expression within a liferay configuration file for the password policies.
Ok, I've rewritten your expression slightly, this is what I came up with:
String pattern = "^(?=.*[\\d().{}?!$&*%=+_-])(?=.*[a-z])(?=.*[A-Z]).{8,}$";
This matches any string with
You want a XOR logical operation, not a OR.
OR is true:
A | B | o/p
T | T | T
F | T | T
T | F | T
F | F | F
XOR is true:
A | B | o/p
T | T | F
F | T | T
T | F | T
F | F | F
Exclusive Or in Regular Expression
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With