import re
matches = []
def repl(m):
	matches.append(m.group())
	return "{}\n".format(m.group())
	
s = 'I want to be able to replace many words, especially in this sentence, since it will help me solve by problem. That makes sense right?'
pattern = re.compile(r'words[,]|sentence[,]|problem[.]')
s = re.sub(pattern, repl, s)

print(s)
print(matches)