Question: how to check if a string matches a pattern in python?
Answer: Use re. match() to check if a string matches a pattern re. match(pattern, string) tests if the regex pattern matches string . Use bool() on the returned match object to return a true or false value.