Regular Expression For Password Field

前端 未结 2 1952
耶瑟儿~
耶瑟儿~ 2021-01-23 01:04

I need a regular expression for a password field that:

  • Must have 1 number

  • Must have 1 letter (uppercase)

  • Must have 1 letter (low

2条回答
  •  臣服心动
    2021-01-23 01:38

    Use [a-zA-Z0-9] instead of . and anchor your regex:

    ^((?=.*\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,})$
    

提交回复
热议问题