Вот шаблон буквального регулярного выражения, который вы описали нам:
^[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";
}
Этот шаблон регулярного выражения говорит:
^ 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 string