import re
regexPattern = '(?s)^(?!.*(?:word1|word2|word3)).*$'
mytext= 'jsdjsqd word1dsqsqsword2fjsdjswrod3sqdq'
print(re.sub(regexPattern, "P", mytext))
aW1wb3J0IHJlCnJlZ2V4UGF0dGVybiA9ICcoP3MpXig/IS4qKD86d29yZDF8d29yZDJ8d29yZDMpKS4qJCcgIApteXRleHQ9ICdqc2Rqc3FkIHdvcmQxZHNxc3Fzd29yZDJmanNkanN3cm9kM3NxZHEnCnByaW50KHJlLnN1YihyZWdleFBhdHRlcm4sICJQIiwgbXl0ZXh0KSk=