Solved

Need Help with Password RegEx

Posted on 2013-11-20
2
449 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
Comment Utility
(?=.{6})(?=.*\d.*\d)(?=.*[A-Z])(?=.*[a-z])(?=.*[!@#$%*.\\+])
0
 
LVL 19

Author Comment

by:Daniel Van Der Werken
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 …
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

762 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

6 Experts available now in Live!

Get 1:1 Help Now