Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Meaning of this line of code

Posted on 2008-10-12
6
Medium Priority
?
257 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
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

688 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