This is how you can use a list of strings in regex functions like the sub, find-all, etc. It also adds word boundaries so it will not match parts of other strings(e.g. Nick in Nicky).
import re names=['Billy','George','Nick'] compiled_list=re.compile("|".join(["\\b"+i+"\\b" for i in names])) test_string='Names: Billy, George, Nick, Nicky' re.sub(compiled_list, '',test_string)
'Names: , , , Nicky'