I am parsing hex data with python regex. I have the following packet structure:
'\xaa\x01\xFF\x44'
- \xaa - start of packet
- \x01 - data length [value can vary from 00-FF]
- \xFF - data
- \x44 - end of packet
i want to use python regex to indicate how much of the data portion of the packet to match as such:
r = re.compile('\xaa(?P<length>[\x00-\xFF]{1})(.*){?P<length>}\x44')
this compiles without errors, but it doesnt work (i suspect because it cannot convert the hex value to an appropriate integer) Is there a method by which this can be accomplished in python?
Background: I have been using erlang for packet unpacking and I was looking for something similar in python
Aucun commentaire:
Enregistrer un commentaire