It seems that only a function with no pattern matching or recursion works here.
checkTokenName :: TokenName -> Bool
checkTokenName tn = lengthOfByteString bs > 3
&& lengthOfByteString bs < 6
&& checkInt tokNum tokNumLen
where
bs = unTokenName tn
tokNum = sliceByteString 3 2 bs
tokNumLen = lengthOfByteString tokNum
isNum i = Builtins.greaterThanInteger i 47 && Builtins.lessThanInteger i 58
checkInt :: BuiltinByteString -> Integer -> Bool
-- No recursion or pattern matching !?!?
checkInt bs' len = (len == 1 && isNum (indexByteString bs' 0)) ||
(len == 2 && isNum (indexByteString bs' 0) &&
isNum (indexByteString bs' 1))