. : - :
boolean isValidSomethingOrOther (string):
if string.length() != 4:
return false
for each character in string:
if not character.isNumeric():
return false
if string.toInt() > 1331:
return false
return true
, , , , ( RE , ):
^0[0-9]{3}|1[0-2][0-9]{2}|13[0-2][0-9]|133[01]$
- 0000-0999.
- 1000-1299.
- 1300-1329.
- 1330 1331.
Update:
, , - . , , :
if isValidSomethingOrOther(str) ...
SomethingOrOther - -. , , (, ).
, , .
, "prime-number-less-than-1332". , - ( ), , , , :
^2|3|5|7| ... |1327$
.