Regular expressions for password validation

后端 未结 2 1445
遥遥无期
遥遥无期 2021-01-20 10:02

I need to validate a password that matches the following criteria:

  • minimum 8 characters
  • contain a combination of numbers and letters
  • must not
相关标签:
2条回答
  • 2021-01-20 10:41

    Try:

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

    See it @work

    0 讨论(0)
  • 2021-01-20 10:47

    simple not most efficient way:

    ^[a-zA-Z0-9!.-_]{8,}$
    

    Replace !.-_ with the list of special characters you'd like to allow

    0 讨论(0)
提交回复
热议问题