Solved

Meaning of this line of code

Posted on 2008-10-12
6
252 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to print dynamic Google map and directions? 1 23
Mouse event to control image and transparency. 4 34
Jquery 2 23
Override MS CSS in SharePoint Online Modal Form 19 43
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…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

856 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