starter trying to figure out a binary pattern match

Felipe Vieira fmv1992@REDACTED
Thu Oct 21 03:54:00 CEST 2021


Hey folks, I have just started learning Erlang and I'm loving it.

I'm going through Armstrong's "Programming Erlang" and I'm trying to build
on "Reading MP3 Metadata".

He patter matches with:

```
parse_v1_tag(<<$T,$A,$G, Title:30/binary, Artist:30/binary, ⋯
```

I tried the following (and variations):

1.

```
-define(ID3V2_HEADER, "TAG").
⋯
is_id3v2(<<?ID3V2_HEADER, Tag:(128 - byte_size(?ID3V2_HEADER))/binary>>) ->
```

2.

```
-define(ID3V2_HEADER, <<"TAG":3/binary>>).
⋯
is_id3v2(<<?ID3V2_HEADER, Tag:(128 - byte_size(?ID3V2_HEADER))/binary>>) ->
```

And I'm trying to achieve a match like this (which also does not work, but
states more clearly my intentions):

```
<<"TAG">> ++ <<X>> = <<84,65,71,73,86,46,32,87,46>>.
```

Is there a way to achieve this together with the `128 -
byte_size(?ID3V2_HEADER))/binary>>` calculation?

Best,

PS: is there a more informal/chat-like place to ask these kinds of
questions?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20211020/f240d3bc/attachment.htm>


More information about the erlang-questions mailing list