I need to validate a 12 digit number. In which,
A 2-digit value is less than 100 by definition (max value is 99), so you don't need to check for that. This regex will meet your other needs:
^\d{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])\d{6}$
It starts with any 2 digits; then either 01-09
or 10-12
; followed by one of 01-09
, 10-19
, 20-29
or 30-31
; followed by 6 digits.
Update
If you can't use \d
in your pattern, replace it with [0-9]
i.e.
^[0-9]{2}(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01])[0-9]{6}$