Myles McDonnell
Myles McDonnell

Reputation: 13335

Erlang Binary Split

I need to split a binary like so

<<"one|two|three|four|five">>

into

[<<"one">>,<<"two">>,<<"three">>,<<"four">>,<<"five">>]

I'm nearly there

binary:split(<<"one|two|three|four|five">>, <<"|">>, []).

But I need to make the scope global to split the entire binary and not just the first item. The answer is staring me in the face here http://www.erlang.org/doc/man/binary.html#split-3 but I'm having trouble working out from the documentation how to specify the scope as global?

Upvotes: 2

Views: 469

Answers (1)

Myles McDonnell
Myles McDonnell

Reputation: 13335

as usual, blindingly obvious once you have worked it out:

binary:split(<<"one|two|three|four|five">>, <<"|">>, [global]).

Upvotes: 3

Related Questions