Couldn't get how re.match(patern, string) works. I need to check if string mathes regular expresion. For example - string should match at least 9 at most 10 (not more!) alpha-numeric symbols:
pattern = '[a-zA-Z0-9]{9,10}'
string_not_match = 'jaguargames.infinity'
string_match = 'kj12345678'
bool(re.match(pattern, string_not_match)) # True but why???!!!!
bool(re.match(pattern, string_match)) # True as expected
I tried
bool(re.compile('[a-zA-Z0-9]{9,10}').match(string_not_match))
but it't just a different syntax and result is still True. It works weird - it matches 10 symbols of the string and returns True.
How I get False to string_not_match and True to string_match for pattern '[a-zA-Z0-9]{9,10}' ?
UPD: The pattern to match whole string should be '^[a-zA-Z0-9]{9,10}$'. Thanks to @MarkTolonen and @EftalGezer.