开发者

binary split and the options

开发者 https://www.devze.com 2023-02-05 13:50 出处:网络
Why is this function returning 3 elements ? [<<\"12345\">>,<<\"67890\">>,<<>>]

Why is this function returning 3 elements ?

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


test3()->
    test4(<<"12345\r\n67890\r\n">>).
test4(Data)->
    X = binary:split(Data, [<<"\r\n">开发者_Go百科;>],[global]), 
    X.


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]), 
0

精彩评论

暂无评论...
验证码 换一张
取 消