6.2.4. Match Objects Match objects always have a boolean value of True. Since match() and search() return None when there is no match, you can test whether there was a match with a simple if statement: match = re.search(pattern, string) if match: process(match) Match objects support the following methods and attributes: match.expand(template) Return the string obtained by doin..