Solved

Need Help with Password RegEx

Posted on 2013-11-20
2
451 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

16 Experts available now in Live!

Get 1:1 Help Now