S
sklett
I have an Intel hex file I need to parse. I want to run a regex on each
line to get the separate sections.
the format is like this:
:llaaaatt[d...]cc
where:
: - starts the record
ll - is the length of the data section([d...]) in hex
aaaa - is the address of the data in hex
tt - is the type in hex
[d...] are the data bytes in hex, this is a variable length section
cc - checksum in hex
So I need a pattern that will separate all the sections. I can get most of
them, but the variable data section I'm not sure. it basically will start
at index 9 and be ll long.
I'm thinking something like this (*note: I don't need section tt):
@"?<ll>(\w{2}))(?<aaaa>(\w{4}))\w{2}(?<d>(\w+))(?<cc>(\w{2}))";
It works, but I'm very new to Regex and not sure if I could do this a better
way. Do you see any improvements that could be made?
Thanks for reading!
Steve
line to get the separate sections.
the format is like this:
:llaaaatt[d...]cc
where:
: - starts the record
ll - is the length of the data section([d...]) in hex
aaaa - is the address of the data in hex
tt - is the type in hex
[d...] are the data bytes in hex, this is a variable length section
cc - checksum in hex
So I need a pattern that will separate all the sections. I can get most of
them, but the variable data section I'm not sure. it basically will start
at index 9 and be ll long.
I'm thinking something like this (*note: I don't need section tt):
@"?<ll>(\w{2}))(?<aaaa>(\w{4}))\w{2}(?<d>(\w+))(?<cc>(\w{2}))";
It works, but I'm very new to Regex and not sure if I could do this a better
way. Do you see any improvements that could be made?
Thanks for reading!
Steve