You have to parse the inputs from left to right for all possible numbers of digits.
For 0 to 12 this would be 0 to 9 and 10 to 12. So a possible regex might be
([0-9])|(1[0-2])
For 30 to 300 with 30 to 99, 100 to 299, and 300:
([3-9][0-9])|([1-2][0-9][0-9])|(300)
However, when using this in a validation function it would be much easier and faster to use
if
conditions after getting and optionally trimming the input (which has to be done for the regex too) and converting to integer.