Bertaud
Bertaud

Reputation: 2928

binary split and the options

Why is this function returning 3 elements ?

[<<"12345">>,<<"67890">>,<<>>]


test3()->
    test4(<<"12345\r\n67890\r\n">>).
test4(Data)->
    X = binary:split(Data, [<<"\r\n">>],[global]), 
    X.

Upvotes: 2

Views: 703

Answers (1)

Kyle d&#39;Oliveira
Kyle d&#39;Oliveira

Reputation: 6382

binary:split(Subject,Pattern,Options)

will split the binary object into the part of the binary that is before the splitting delimiter, and the parts after.

Consider adding the trim options for the binary:split, i.e.

binary:split(Data, [<<"\r\n">>],[trim,global]), 

Upvotes: 9

Related Questions