I don't quite understand the problem. Is it that:
-
you are given a 10-digit core serial number in the range 0000000000 .. 9999999999 and a year number in the range 18 .. 22 and possibly a month number (in what range: 0 .. 11 or 1 .. 12?), and you must figure out all possible 15-, 14-, 13-, 12- and 10-digit full serial numbers that might result (with and without a leading zero for the month number); or
-
you are given a 13-digit full serial number and you must determine which of two possible formats it is in (the 15-, 14-, 12- and 10-digit full serial number lengths all being unambiguously parsable).
My impression is that the latter problem is the one you face, but I have a nagging doubt...
Give a man a fish: <%-{-{-{-<