[Tutor] escape character regex
Danny Yoo
dyoo at hashcollision.org
Sun Mar 29 00:48:33 CET 2015
> But if I try to match the extra digits at the end like this:
>
>>pchars = re.compile('\x00\x00\x00\x\d+')
>
> I get an error:
>
>>ValueError: invalid \x escape
You should just be able to say:
pchars = re.compile('\x00\x00\x00..')
because it looks like you're trying to grab at the last two characters.
Hexadecimal escape is just another notation for expressing a character.
So, for example, take a look at this string.
'\x68\x69\x20\x69\x61\x6e'
Try printing it.
Hope this helps.
More information about the Tutor
mailing list