I am trying to replace a string in a file using python re lib. But I failed on replacing some texts with some special characters, like, (), ?, etc. Can anyone help me look at this issue?
I attached my code in here.:
filterText = '\"' + sheet.row_values(row)[1] + '\"';
print "filterText = %s"%filterText;
pattern = re.compile(filterText, re.S);
replacedText = '\"' + sheet.row_values(row)[2] + '\"';
print "replacedText = %s"%replacedText;
if filterText == "English (UK)":
    print "replacedText = %s"%replacedText;
fileContent = re.sub(pattern, replacedText, fileContent);
 
     
    