Regular Expression for Password Strength Validation

后端 未结 6 1253
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 02:21

I have written a regular expression which could potentially be used for password strength validation:

^(?:([A-Z])*([a-z])*(\\d)*(\\W)*){8,12}$
6条回答
  •  执笔经年
    2021-01-01 02:53

    I think you'll have to check each group independently. Pseudo-code:

    bool[] array = {};
    array[0] = pwd.match(/[A-Z]/);
    array[1] = pwd.match(/[a-z]/);
    array[2] = pwd.match(/\d/);
    array[3] = pwd.match(/[!_.-]/);
    
    int sum = 0;
    for (int i=0; i

提交回复
热议问题