开发者

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">开发者_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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜