Correct regex for a password-type field -
working on password-field.
the regex expression field container letters (lowercase, uppercase), digits , special characters this:
^([a-z,a-z,0-9,#,$,%,&,_,]{8,20})*$
tell me please, how should modified if want every pass phrase have @ least 1 lowercase, 1 uppercase , 1 digit?
for example, 3-characters long pass is:
- 'ab3' - pass
- 'ab3' - fail
you need use lookaheads , need remove commas present inside character class.
^(?=.*?[a-z])(?=.*?[a-z])(?=.*?\d)[a-za-z0-9#$%&_]{8,20}$
note password must atleast 8 , atmost 20 chars long.
Comments
Post a Comment