I have a regex that has the following rules:
+ Must contain lower case letters
+ Must contain upper case letters
+ Must contain a number
+ Must contain a (defined)special character
+ At least 8 chars
This works, and my regex looks like this:
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[~@#\$%\^&\*_\-\+=`|{}:;!\.\?\"()\[\]]).{8,25})
Now I want to change this regex only in one: Special characters should be available (and only those that I allow), but should be optional (no longer required) anywhere on the line. So the new rule will be
+ MAY contain (defined) special characters
What do I need to change for this?
Examples:
NicePassw0rd - NOT OK now, should be
NicePassw0rd%% - OK now (and still should be)
NicePassword - NOT OK now and shouldnt
You can check my regex: https://regex101.com/r/qN5dN0/1
source
share