binary expression with fixed and variable fields

info info@REDACTED
Tue Jun 29 19:22:01 CEST 2010


Hi all,
I have a string composed of several fixed and variable fields. I would like to parse this string as binary expression.
I checked the example with an IP datagram (the variable fields are to the end ...):

 <<field1:size1,field2:size2,field3:size3,field4:size4,field5:size5>>

If the size3 of the field3 is variable,how to parse the string ?

<<field1:size1,field2:size2,Rest/binary>>  but after ?

If a field is empty, how to detect it ?
If a char (e.g comma) is between each field, is it always possible to use the binary syntax ?

Does exist a general approach in Erlang ?

John


More information about the erlang-questions mailing list