[erlang-questions] [enhancement] string:split/2

Robert Virding rvirding@REDACTED
Thu Oct 9 11:54:13 CEST 2008


2008/10/9 Richard O'Keefe <ok@REDACTED>

>
> (3) unjoin:unjoin(";;;abc;;de;f;g;;", ";;").
>     [[],";abc","de;f;g",[]]
>
>     Is that the right answer, or should it be
>     [";","abc","de;f;g",[]]?


Either, depending on how you define your string. It could either start/end
with a separator, or start/end with data. The important thing is to define
it and should be the same at either end. For example regular expression
libraries often have start/end with data.

Your first example is start/end with data, while your second is start/end
with separator.

I would personally prefer the name split even though unjoin might more
correct. Looking at the documentation for string:join it is start/end data
so I definitely feel that split/unjoin should do the same so that they are
inverses.

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081009/4040029b/attachment.htm>


More information about the erlang-questions mailing list