I wrote a program to read in Windows DNS debugging log, but inside always got some funny characters in the domain field.
Below is one of the example:
(13)\xc2\xb5\xc2\xb1\xc2\xbe\xc3\xa2p\xc3\xb4\xc2\x8d(5)example(3)com(0)'
I want to replace all the \x..
with a ?
I explicitly type \xc2 as follows works
line = '(13)\xc2\xb5\xc2\xb1\xc2\xbe\xc3\xa2p\xc3\xb4\xc2\x8d(5)example(3)com(0)'
re.sub('\\\xc2', '?', line)
result: '(13)?\xb5?\xb1?\xbe\xc3\xa2p\xc3\xb4?\x8d(5)example(3)com(0)'
But its not working if I write as follow:
re.sub('\\\x..', '?', line)
How I can write a regular expression to replace them all?