I am creating a regexp for password verification in the Java application as a configuration parameter.
is regexp:
^. * (? =. * {0- 9]) (? =. * [AG]) (? =. * [AG]) (? =. * [@ # $%] ^ & Amp; + =]). * $
Password policy is:
-
Less it
-
At least one lower alpha four letter and one upper alpha character
-
Includes a set of special characters There is at least one letter within (
@ #% $ ^
etc.) -
This does not include location, tab, etc.
at least 8 characters
I can not find just 5 marks.
Can someone help me? >
Try this:
^ (? =. * [0-9]) (? =. * [Az]) (? =? * [AZ]) (? =?. * [@ # $% ^ & Amp; + =]) (? = \ S + $) {8,} $
explanation:
^ # start-string (? =. * [0-9]) # points at least one Times should be (? =. *. * [AG]) # should be at least once the letter (? =. * [AZ]) # At least once (============= =========================== At least once a special character should be at least once (? = \ S + $) # No white space is allowed, the entire string. {8,} # Anything, at least eight places, though $ # end-of-string
adding, modifying individual rules Easy to remove or delete, because each rule is an independent "module".
(? = =. * [Xyz]) Build the entire string (
. * < / Code>) and the event behind where the
[xyz]
match can be successful, if it is found, if it is found to be [xyz]
, otherwise it will fail
Optional will use a reluctant qualifier: (? =? *? [Xyz])
. To check the password, it will hardly make any difference, too long Time till date C it may be more efficient version.
The most efficient version (but the hardest to read and maintain, so prone to the most error) will be (? =? [^ Xyz] * [xyz]),
, of course . For this length of a regex and for this purpose, I would dis-recommend that way, because it is not a real benefit.
Comments
Post a Comment