re.sub(regex, replacement, subject)
Each match of regular expression in string subject will be replaced with replacement of string.
import re
str = "yes I said yes I will Yes."
res = re.sub("[yY]es", "no", str)
print(res)
no I said no I will no.