Solved

Need Help with Password RegEx

Posted on 2013-11-20
2
466 Views
Last Modified: 2013-11-20
Need help with a password RegEx I'd like to use. I've been up on the sites, but I'm not that familiar with RegEx and would appreciate some help.

Note I'm using .NET 4.0 and C#, but I'd like it to work in JavaScript as well if possible.

Password Requirements:
====================

1. Must be at least six characters long.
2. Must contain at least two numbers.
3. Must have at least one upper case character.
4. Must have at least one lower case character.
5. Must have at least one of the following special characters: !@#$%*.\+

My main problem is I can't seem to match regardless of placement. RegEx patterns are good with things like, a phone number: They have a placement you match against. You do three digits, then three digits, then four digits.

Email addresses have a string with letters and number, then an @ sign, and then more letters and numbers and a dot and a domain.

We have order here. My password doesn't have necessary order. I can do "P@SSword123" or "PA$$W04d" or "paSS30r*" and note that the special character and be at any location.

I was thinking nested square brackets like this [[\w][\d][etc]] would work, but it doesn't.

I'd appreciate any help on this. Thanks.
0
Comment
Question by:Daniel Van Der Werken
[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
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39662882
(?=.{6})(?=.*\d.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%*.\\+])
0
 
LVL 20

Author Comment

by:Daniel Van Der Werken
ID: 39663037
I don't think, from what I've read, that (?= works for JavaScript. Does it? If not, do you have a JavaScript equivalent?
0

Featured Post

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!

Question has a verified solution.

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

These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

615 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