)我们希望设置一个特殊的条件(基于PHP的Preg_match正则表达式)来验证表单上的一个数字。
非常感谢您能在这方面帮助我们,在PHP Preg_match中为正则表达式提供良好的“语法”来验证表单上的该字段!)
感谢社会各界的支持和帮助!
问候
发布于 2019-05-25 06:31:25
下面是您向我们描述的文字regex模式:
^[12]\d{2}(?:0[1-9]|1[0-2])\d{8}$示例脚本:
$input = "1231212345678";
if (preg_match("/^[12]\d{2}(?:0[1-9]|1[0-2])\d{8}$/", $input)) {
echo "MATCH";
}这个regex模式说明:
^ from the start of the string
[12] match 1 or 2 as the first digit
\d{2} then match any digits in the 2nd and 3rd position
(?:0[1-9]|1[0-2]) match 01, 02, ..., 12 as the two digit month
\d{8} then match any other 8 digits
$ end of stringhttps://stackoverflow.com/questions/56302301
复制相似问题