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

Robert Virding <>
Sun Oct 12 22:22:17 CEST 2008


Can we end the language discussion? :-)

I suggest a function string:split/2 which splits the input string with the
separator and assumes that there is no separator and either end of the
string. So:

string:split("ab:de:fg", ":") ==> ["ab","de","fg"]
string:split(":ab:de:fg:", ":") ==> [[],"ab","de","fg",[]]

We call it split because it sounds better inspite of it being an unjoin.
This also matches what will be in the re module (if they get it right) and
what is in the old regexp module.

And I don't really care what its relationship to join is called. :-)

Robert

2008/10/10 Alex Chateau <>

> > string:join/2 is not a surjective function, not a bijective one:
>
> Sorry, string:join/2 _is_ a surjective function
>
> --
> Alex Chateau
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20081012/76f1ce53/attachment.html>


More information about the erlang-questions mailing list