Regular Expression - Password

113 views Asked by At

What kind of string(password) does this regular expression match with /^(\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*){6-20}$/ ?

I tried passwords with 6-20 characters which includes lower case[a-z], upper case[A-Z] and one numeral(0-9) but no joy!

1

There are 1 answers

0
kjpires On

If this is Perl, the string must a digit, a lower-case letter, an upper-case letter plus any number of other \w characters and literally {6-20} at the end of the string. For example, 1aA{6-20} is true.

I think original author indented to have {6,20} instead of {6-20}.

It's a complicated regex. I think the following would be easier to understand and quicker:

/^\w{6,20}$/ && /\d/ && /[a-z]/ && /[A-Z]/