Column 1 in my csv has the target_string (to be replaced) and column 2 is the context (text_column). I can't get it to only remove the string when it is stand alone. I have tried adding \b, but that doesn't work.
Text : "Foo, FOOBAR FOO FOOBAR FOO FOO FOOBAR."
string_column = col [1]
text_column = col [2]
string_replacement = "BAR"
text_column = re.sub(string_column, string_replacement, text_column, flags=re.IGNORECASE)
What I get is : "BARBAR BAR BARBAR BAR BAR BARBAR."
What I need is: "FOOBAR BAR FOOBAR BAR BAR FOOBAR."
EDIT I don't think this is a duplicate of the linked question. Those responses wouldn't have helped me, and are far more complicated than the simple solution provided here.