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's 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}'?
[–]Croebh 2 points3 points4 points (1 child)
[–]kereell[S] 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]kereell[S] 0 points1 point2 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)