dongshungai4857 2019-06-08 08:33
浏览 157

这个正则表达式是什么意思/^.*(?=.{4,5})(?=.*[az])(?=.*[AZ])(?=.* [0-9])。 * $ / [重复]

This question already has an answer here:

Can someone elaborate the following regular expression:

if($pass == $re_pass) {
    //password validation
    $pattern_up = "/^.*(?=.{4,56})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$/";

    if(!preg_match($pattern_up, $pass)) {
        $errPass = "Must be at lest 4 character long, 1 upper case, 1 lower case letter and 1 number exist";
    }
}

what I want to achieve is to check the entered password is between the number of 4 and 56. I already specified it in the code. However, when I tried, it can accept more than that range.

My question, is how i can specify the upper limit, i dont want to exceed 56 characters long. And if you can elaborate it more, so i can understand it more. this code is not made by me.

Thanks,

I am trying to do sign up page in php

if($pass == $re_pass) {
    //password validation
    $pattern_up = "/^.*(?=.{4,56})(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).*$/";

    if(!preg_match($pattern_up, $pass)) {
        $errPass = "Must be at lest 4 character long, 1 upper case, 1 lower case letter and 1 number exist";
    }
}
</div>
  • 写回答

1条回答 默认 最新

  • dqzve68846 2019-06-08 09:26
    关注

    Just use anchors: ^.{4,56}$

    ^ - match beginning of a string

    $ - match end of a string

    .{4,56} - match any character at least 4 and at most 56 times

    Demo

    You can use it in positive lookahead: (?=^.{4,56}$)

    评论

报告相同问题?

悬赏问题

  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题