From the Python 3 documentation:
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)
pull/487/head
Dimitri Papadopoulos2 years agocommitted byAdrien Vergé