[erlang-questions] how: Matching empty binaries at the beginning

Bjorn Gustavsson bjorn@REDACTED
Thu Nov 15 21:25:31 CET 2007


A binary without a size will *always* match to the end of the binary
even if the binary is not at the end:

Eshell V5.5.5.5  (abort with ^G)
1> <<Empty/binary, Tail/binary>> = <<"ABC">>.
<<"ABC">>
2> Empty.
<<"ABC">>
3> Tail.
<<>>
4>

This is probably not what is expected.

Therefore, in R12B we only allow binaries without size at the
end of a binary pattern:

Eshell V5.6  (abort with ^G)
1> <<Empty/binary, Tail/binary>> = <<"ABC">>.
* 1: a binary field without size is only allowed at the end of a binary pattern
2>

/Bjorn

> > On 11/15/07, Juan Jose Comellas <juanjo@REDACTED> wrote:
> > >
> > > Why is this expression not matching?
> > >
> > > A = <<"ABC">>,
> > > Empty = <<>>,
> > > <<Empty/binary, Tail/binary>> = A.
> >

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB



More information about the erlang-questions mailing list