You should be able to divide it into capabilities as follows:
^([1-9]|[1-5][0-9]|60|all)$
This gives you four possibilities:
[1-9] single digits.[1-5][0-9] : all from ten to fifty nine.60 : sixty.all : your all option.
But keep in mind that regular expressions are not always the answer to every question.
Sometimes they are less useful for complex value checks (although in this case it is quite simple). Something like the following (pseudo-code):
def isAllOrOneThruSixty(str): if str == "all": return OK if str.matches ("[0-9]+"): val = str.convertToInt() if val >= 1 and val <= 60: return OK return BAD
sometimes it can be, although more detailed, also more readable and supported.
source share