I'm trying to use regex in python to replace strings. I'd like to replace "SERVERS)" with "SERV" in a string.
example_String = "This is a great SERVERS)"
re.sub("SERVERS)","SERV", example_String)
I expected it to be a straight forward swap, but as I read more into the error, it looks like I need to set the regex pattern to read the ")" as a regular character and not a special regex character.
I'm not very familiar with regex , and would appreciate the help!
Edit : I'm importing data from a database (which is user input), there's quite a few similar issues as mentioned in the question. re.escape() fits the bill perfectly , thanks!