Regex for 2 letters followed by 4 digits

前端 未结 5 1436
你的背包
你的背包 2020-12-22 13:31

The string should begin with \"S2\" followed by any 4 digits.

A matching string is \"S20165\".

I\'m trying with the following code, but it always echos OK ev

5条回答
  •  抹茶落季
    2020-12-22 14:13

    $string='S20104';
    if(preg_match('/^S2[0-9]{4}$/', $string)){
        echo 'OK';
    }
    else{
        echo 'NOT OK';
    }
    

提交回复
热议问题