Not suitable for regular expression, but if you insist:
^(?:36[0-5]|3[0-5][0-9]|[12][0-9][0-9]|[1-9][0-9]|[1-9])$
This does not allow leading zeros. If you want to allow them, let me know.
The above expression may be slightly reduced to
^(?:36[0-5]|3[0-5]\d|[12]\d{2}|[1-9]\d?)$
but I believe that the first solution will be more readable. YMMV.
source
share