>>>
>>> re.search(r'^\d{3, 5}$', '90210') # {3, 5} 3 or 4 or 5 times
>>> re.search(r'^\d{3, 5}$', '902101') # {3, 5} 3 or 4 or 5 times
>>> re.search(r'^\w{3, 5}$', 'hello') # {3, 5} 3 or 4 or 5 times
>>> re.search(r'^\w{3, 5}$', 'hell') # {3, 5} 3 or 4 or 5 times
>>>
All of the above suppose to should work, with {} quantifier
Question:
Why r'^\d{3, 5}$'
does not search for '90210'
?
There should be no space between
{m
and,
andn}
quantifier:BTW,
902101
does not match the pattern, because it has 6 digits: