new to regex here
I am trying to create a very basic pattern matching where user input has to be exactly 3 digits. In this example, for me it is invalid if I have less than 3. But any input with 3 or more digits is accepted. Shouldn't this be invalid if its greater than 3 digits?? Am I doing something wrong here?
import re
pattern = "[0-9]{3}"
user_input = input()
if(re.search(pattern, user_input)):
print("valid")
else:
print("invalid")