Link to home
Start Free TrialLog in
Avatar of Daniel Van Der Werken
Daniel Van Der WerkenFlag for United States of America

asked on

Need Help with Password RegEx

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.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Daniel Van Der Werken

ASKER

I don't think, from what I've read, that (?= works for JavaScript. Does it? If not, do you have a JavaScript equivalent?