In the source file, I have within the line the following data item (as is, len=11):
(?i:\'sa\')
When I pass it to a re.match, the matching (.groupdict()) value, written into a file, appears to be:
(?i:\sa\)
(len=9)
Question is, how to I preserve value raw (as in the following b example), between re.match and file.write
>>> a = '(?i:\'sa\')'
>>> b = r'(?i:\'sa\')'
>>> len(b)
11
>>> len(a)
9
>>> len(b)
11
>>> print b
(?i:\'sa\')
Note, since I am processing large and complex files provided by third party, I do not want nor can I change from 'a\'b' to "b'b" but must keep things as they are.
Probably
string_escapeis what you need: