Use re.subn
Perform the same operation as sub(), but return a tuple (new_string, number_of_subs_made).
and then check the number of replacements that were made. For example:
text2, numReplacements = re.subn(pattern, repl, text1)
if numReplacements:
# did match
else:
# did not match