Solved

Meaning of this line of code

Posted on 2008-10-12
6
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

630 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