Regular Expression for a password

J

Joe

Hello,

I want to verify that a password is:
- Minimum 7 characters (can be any character)
- Includes at least 1 number.

I thought this would work but it does seem to:
^(?=.*[a-z])(?=.*[A-Z]).{7,}$

Thanks,
Joe
 
J

Jesse Houwing

Hello Joe,
Hello,

I want to verify that a password is:
- Minimum 7 characters (can be any character)
- Includes at least 1 number.
I thought this would work but it does seem to:
^(?=.*[a-z])(?=.*[A-Z]).{7,}$
Thanks,
Joe

There is no check for a number in there at all....

^(?=.*[0-9]).{7,}$

should do the trick.
 
L

lue

Joe
see this link
http://davidhayden.com/blog/dave/archive/2004/09/25/501.aspx
password complexity in your applications:
^.*(?=.{7,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=]).*$

The regular expression enforces the following rules:

a.. Must be at least 7 characters
b.. Must contain at least one one lower case letter, one upper case
letter, one digit and one special character
c.. Valid special characters (which are configurable) are - @#$%^&+=


Regards

Lue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top