Regular Expressions: Is there an AND operator?

后端 未结 12 2045
刺人心
刺人心 2020-11-21 06:34

Obviously, you can use the | (pipe?) to represent OR, but is there a way to represent AND as well?

Specifically, I\'d like to

12条回答
  •  自闭症患者
    2020-11-21 07:18

    Use AND outside the regular expression. In PHP lookahead operator did not not seem to work for me, instead I used this

    if( preg_match("/^.{3,}$/",$pass1) && !preg_match("/\s{1}/",$pass1))
        return true;
    else
        return false;
    

    The above regex will match if the password length is 3 characters or more and there are no spaces in the password.

提交回复
热议问题