Problem with Replacing special characters in a string
- by Hossein
Hi,
I am trying to feed some text to a special pupose parser. The problem with this parser is that it is sensitive to ()[] characters and in my sentence in the text have quite a lot of these characters. The manual for the parser suggests that all the ()[] get replaced with \( \) \[ \]. So using str.replace i am using to attach \ to all of those charcaters. I use the code below:
a = 'abcdef(1234)'
a.replace('(','\(')
however i get this as my output:
'abcdef\\(1234)'
What is wrong with my code? can anyone provide me a solution to solve this for these characters?