regular expression for password with few rules

前端 未结 3 1705
迷失自我
迷失自我 2021-01-16 05:54

I want a function checkPassword function, which should check if the password parameter adheres to the following rules:

  1. Must be longer than 6 characters
3条回答
  •  孤街浪徒
    2021-01-16 06:18

    The best way would be to use two separate regular expressions. First, make sure the password matches this first one, which checks for adherence to rules #1 and #2:

    [A-Za-z0-9#$\/\\\+]{6,}
    

    Then, make sure the password does not match this second regular expression, which checks for the presence of a sequence of 3 consecutive numbers anywhere in the password:

    \d{3}
    

提交回复
热议问题