Skip to content

Instantly share code, notes, and snippets.

@etrepum
Created January 13, 2014 20:01
Show Gist options
  • Save etrepum/8406970 to your computer and use it in GitHub Desktop.
Save etrepum/8406970 to your computer and use it in GitHub Desktop.
Example of Erlang's native binary matching syntax, using the example from sacker.py https://github.com/shamrin/pyxtf/blob/master/sacker.py The `1>`, `2>` are interpreter prompts, like Python's `>>>`.
1> <<16#ff:16/little, Data:4/binary, _:4/binary, Byte, Rest/binary>> = <<"\xff\x00DATA1234\x10something else">>.
<<255,0,68,65,84,65,49,50,51,52,16,115,111,109,101,116,
104,105,110,103,32,101,108,115,101>>
2> Data.
<<"DATA">>
3> Byte.
16
4> Rest.
<<"something else">>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment