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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top