M
Mike Blake-Knox
I'm trying to use regular expressions to match variable length fields
in a record. The fields are laid out with their length in the first
byte and the data following immediately after the length. I was hoping
to do it by matching the length (two hex characters) then using a
backreference to the length in a quantifier. (If the string is
0808313436382e30000e113431 and the regex is
^(?'length'[0-9a-fA-F]{2})([0-9a-fA-F]{\k<length>}) The length capture
is 08 and I was hoping that ([0-9a-fA-F]{\k<length>} would match the
next eight bytes. Unfortunately, there isn't a match.
Would anyone have a suggestion for doing this?
Thanks
Mike Blake-Knox
in a record. The fields are laid out with their length in the first
byte and the data following immediately after the length. I was hoping
to do it by matching the length (two hex characters) then using a
backreference to the length in a quantifier. (If the string is
0808313436382e30000e113431 and the regex is
^(?'length'[0-9a-fA-F]{2})([0-9a-fA-F]{\k<length>}) The length capture
is 08 and I was hoping that ([0-9a-fA-F]{\k<length>} would match the
next eight bytes. Unfortunately, there isn't a match.
Would anyone have a suggestion for doing this?
Thanks
Mike Blake-Knox