检查号码是从0还是00开始

Tar*_*ari 3 php regex

我想知道如何检查正则表达式或其他什么,如果一个数字从0或00开始我这样做但新手到正则表达式

preg_match("/^[0][0-9]+$/", $number)
Run Code Online (Sandbox Code Playgroud)

Avi*_*Raj 7

您可以尝试以下代码

if (preg_match("~^0\d+$~", $number)) {
     // Yes
}
else {
     // no
}
Run Code Online (Sandbox Code Playgroud)

说明:

^                        the beginning of the string
0                        '0' 
\d+                      digits (0-9) (1 or more times)
$                        before an optional \n, and the end of the
                         string
Run Code Online (Sandbox Code Playgroud)

DEMO