Solved

Meaning of this line of code

Posted on 2008-10-12
6
253 Views
Last Modified: 2012-08-14
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...
passwordStrengthRegularExpression="(?=.{8,})(((?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]))|((?=.*\d)(?=.*[A-Z])(?=.*[\W_]))|((?=.*\d)(?=.*[a-z])(?=.*[\W_]))|((?=.*\d)(?=.*[a-z])(?=.*[A-Z])))

Open in new window

0
Comment
Question by:Camillia
  • 4
  • 2
6 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 22698799
Did you change something when copy to EE?
Because the expression starts with " and does not end so.
And it should start with forward slash: / and end also with forward slash.

0
 
LVL 7

Author Comment

by:Camillia
ID: 22698830
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...
(?=.{8,})(((?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]))
 
|
 
((?=.*\d)(?=.*[A-Z])(?=.*[\W_]))
 
|
 
((?=.*\d)(?=.*[a-z])(?=.*[\W_]))
 
|
 
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])))
 

Open in new window

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 22698853
OK, the expression has to be written this way:

passwordStrengthRegularExpression=/(?=.{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?


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 63

Accepted Solution

by:
Zvonko earned 500 total points
ID: 22698863
You breaked it like this:

(?=.{8,})  // minimum eight charse or more
( // one group out of four

((?=.*[a-z])(?=.*[A-Z])(?=.*[\W_]))  // aaaAAA___
 
|  // or
 
((?=.*\d)(?=.*[A-Z])(?=.*[\W_]))  // 999AAA___
 
|  // or
 
((?=.*\d)(?=.*[a-z])(?=.*[\W_]))  // 999aaa___
 
| or
 
((?=.*\d)(?=.*[a-z])(?=.*[A-Z])))  // 999aaaAAA


0
 
LVL 63

Expert Comment

by:Zvonko
ID: 22698891
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_]

0
 
LVL 7

Author Comment

by:Camillia
ID: 22699230
thanks, let me see.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question