Camillia
asked on
Meaning of this line of code
I've inherited a code that uses below Regular expressions to validate password. I tried upper case, lower case, number and @ but none of it pass this validation..what does this mean?
i think the first one means min of 8 characters...
i think the first one means min of 8 characters...
passwordStrengthRegularExpression="(?=.{8,})(((?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]))|((?=.*\d)(?=.*[A-Z])(?=.*[\W_]))|((?=.*\d)(?=.*[a-z])(?=.*[\W_]))|((?=.*\d)(?=.*[a-z])(?=.*[A-Z])))
ASKER
It's part of a ASP.Net's web.config declaration but that section is exactly the same...
if i break it down...what is each section? i know some means i can enter upper case, i can enter lower case but for example when I enter FirstnameLastname...that doesnt get validated...
if i break it down...what is each section? i know some means i can enter upper case, i can enter lower case but for example when I enter FirstnameLastname...that doesnt get validated...
(?=.{8,})(((?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]))
|
((?=.*\d)(?=.*[A-Z])(?=.*[\W_]))
|
((?=.*\d)(?=.*[a-z])(?=.*[\W_]))
|
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])))
OK, the expression has to be written this way:
passwordStrengthRegularExp ression=/( ?=.{8,})(( (?=.*[a-z] )(?=.*[A-Z ])(?=.*[\W _]))|((?=. *\d)(?=.*[ A-Z])(?=.* [\W_]))|(( ?=.*\d)(?= .*[a-z])(? =.*[\W_])) |((?=.*\d) (?=.*[a-z] )(?=.*[A-Z ])))/
And it checks the password like this:
First check is that there are 8 or more characters: (?=.{8,})
Then the characters has to obay to one of four rules.
Either: lowercase and uppercase and special char (!§$%&/_...)
Or: digit, uppercase special chars
Or: digit lowercase special chars
or: digit lowercase uppercase
The pipe char is the separator with the meaning: or
The braces are groups.
The (?= is the condition prefix for non eating check.
Does it make sense to you?
passwordStrengthRegularExp
And it checks the password like this:
First check is that there are 8 or more characters: (?=.{8,})
Then the characters has to obay to one of four rules.
Either: lowercase and uppercase and special char (!§$%&/_...)
Or: digit, uppercase special chars
Or: digit lowercase special chars
or: digit lowercase uppercase
The pipe char is the separator with the meaning: or
The braces are groups.
The (?= is the condition prefix for non eating check.
Does it make sense to you?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
By the way, \W is a difficult meta char. It means all chars that are not \w
And \w means o-9a-zA-Z_ or in words: all Latin alphanumeric chars and the underscore: _
The \W means anything else, like this: ö!ܧ,$?-(>]%}
And because \w allows _ does the \W not allow _ and it is explicitely added to the set: [\W_]
And \w means o-9a-zA-Z_ or in words: all Latin alphanumeric chars and the underscore: _
The \W means anything else, like this: ö!ܧ,$?-(>]%}
And because \w allows _ does the \W not allow _ and it is explicitely added to the set: [\W_]
ASKER
thanks, let me see.
Because the expression starts with " and does not end so.
And it should start with forward slash: / and end also with forward slash.