RegEx For Strong Password

后端 未结 4 1128
情书的邮戳
情书的邮戳 2020-12-18 00:35

I have the following password requirements:

1) Should be 6-15 characters in length
2) Should have atleast one lowercase character
3) Should have atleast one

4条回答
  •  太阳男子
    2020-12-18 01:15

    Not sure I would use a Regex for that : regex are not always the right tool for any possible kind of job...

    Here, you specified a list of 6 requirements ; so, why not just use 6 different tests, one per requirement ?
    Those 6 different tests, should I add, would be really simple -- while a Regex would be much harder to write (you asked for help -- you would probably not have for the 6 tests).

    This would make your code a lot more easier to understand, I'd bet ;-)
    And also : easier to maintain ; and easier to add/remove/change one of the condition corresponding to one of the requirements.

提交回复
热议问题