views:

73

answers:

2

I have a password validation like the following rules

  1. Should contains at most 15 chars and 8 chars at least
  2. Password should contain 2 numeral character
  3. There is no importance where to put the two numeral chars in start or end even if they anywhere in the password
+10  A: 
^(?=\D*\d\D*\d).{8,15}$
KennyTM
Won't this fail to find alpha chars at the end?
Robusto
@Rob: What alpha chars?
KennyTM
@KennyTM: I should have said non-numeric. The way your regex is written doesn't it have to end with a \d (numeric) char?
Robusto
@Rob: No. Do you know what's a lookahead assertion?
KennyTM
+3  A: 

The best you can do is present your user with an estimate of the strength of their password and let them shoot their own foot if they wish.

Any scheme to force people to make good passwords is doomed by the ability of people to use post-it notes.

msw