[erlang-questions] bug in binary:split with trim?

Hynek Vychodil hynek@REDACTED
Wed Jun 29 10:28:13 CEST 2011


Why not simply?
[X || X<- binary:split(<<"//a/b///">>, <<"/">>, [trim, global]), X=/=<<>>]


On Tue, Jun 28, 2011 at 5:11 PM, Wes James <comptekki@REDACTED> wrote:
> On Tue, Jun 28, 2011 at 3:58 AM, Pablo Platt <pablo.platt@REDACTED> wrote:
>> binary:split with the trim option doesn't remove empty results from the
>> beginning of the binary:
>>
>> binary:split(<<"/a/b/">>, <<"/">>, [global, trim]).
>> [<<>>,<<"a">>,<<"b">>]
>> binary:split(<<"//a/b///">>, <<"/">>, [trim, global]).
>> [<<>>,<<>>,<<"a">>,<<"b">>]
>> Is this a bug?
>> Thanks
>
> Little more processing, but....
>
>
> [list_to_binary(X) || X <- string:tokens(binary_to_list(<<"//a/b///">>),"/")].
>
> [<<"a">>,<<"b">>]
>
>
> or maybe like this:
>
> [Result]=string:tokens(binary:split(<<"//a/b///">>, <<"/">>, [trim,
> global]), [<<>>]).
> [[<<"a">>,<<"b">>]]
> 11> Result.
> [<<"a">>,<<"b">>]
>
> -wes
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill
your boss.  Be a data hero!
Try GoodData now for free: www.gooddata.com



More information about the erlang-questions mailing list