How about:
^(?=.{6})1[0-2]\d{0,4}\**$
this will match all your examples and not match strings like:
1*2*3*
explanation:
The regular expression: (?-imsx:^(?=.{6})1[0-2]\d{0,4}\**$) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- (?= look ahead to see if there is: ---------------------------------------------------------------------- .{6} any character except \n (6 times) ---------------------------------------------------------------------- ) end of look-ahead ---------------------------------------------------------------------- 1 '1' ---------------------------------------------------------------------- [0-2] any character of: '0' to '2' ---------------------------------------------------------------------- \d{0,4} digits (0-9) (between 0 and 4 times (matching the most amount possible)) ---------------------------------------------------------------------- \** '*' (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- $ before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------