I'm using Python 2.7.3 I have the following function:
def is2To4Numbers(q):
if re.match('[0-9]{2,4}',q):return True
else: return False
I'm trying to limit the number of digits from 2 to 4. But I get these results.
>>> is2To4Numbers('1235')
True
>>> is2To4Numbers('1')
False
>>> is2To4Numbers('12345')
True
>>> is2To4Numbers('1234567890')
True
I can't seem to get the right limit. How should i solve this? Are there other ways other than using {m,n}? Or am I even using {m,n} correctly?