I want to create a RE object that matches if the string contains at least one of the elements of a list.
For example, if bad_words["censored","stupid","idiot"] is the list, the RE would match if at least one of them exist.
This is my RE: re.compile("(%s)+" % ("|".join(bad_words)), re.IGNORECASE)
Problem is that ‘youareanidiot’ doesn’t match. What do I have to change in order to make it matched?
Are you using re.match? Try re.search. See Matching vs. Searching from the Python regex docs.