Pass it through a few regular expressions if you can. It will be much cleaner than these monstrous prospects :-)
^[a-zA-Z0-9]{6,10}$ [a-zA-Z] [0-9]
Although some may find this smart, you donβt have to do everything with one regular expression (or even with any regular expression, sometimes just a witness to people who want the regular expression to find numbers between 75 and 4093).
You would rather see nice clean code, for example:
if not checkRegex(str,"^[0-9]+$") return false val = string_to_int(str); return (val >= 75) and (val <= 4093)
or something like:
return checkRegex(str,"^7[5-9]$|^[89][0-9]$|^[1-9][0-9][0-9]$|^[1-3][0-9][0-9][0-9]$|^40[0-8][0-9]$|^409[0-3]$")
I know which one I would prefer to support :-)
source share