I would like match an expression containing a special character.
If I don't have a special character I can do something like
string = "bar foo bar"
print(re.sub("\\bfoo\\b", "", string))
string = "bar foobar"
print(re.sub("\\bfoo\\b", "", string))
>bar bar
>bar foobar
But if I do
string = "bar foo+ bar"
print(re.sub("\\bfoo\+\\b", "", string))
>bar foo+ bar
I would like an expression the matches
string = "bar foo+ bar"
string = "bar foo+.bar"
But not
string = "bar foo+bar"