Solved

Meaning of this line of code

Posted on 2008-10-12
6
249 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now