[erlang-questions] split

Joe Armstrong erlang@REDACTED
Fri Feb 14 10:41:24 CET 2014


I'm sitting here feeling very stupid, can anybody explain to me in terms
that
a child of five could understand what's going on here:

Problem: I want to split a string on repeated  occurrences of the string
"abc"

  so split("123abcabc456") should return [<<"123">>,<<"456">>]

So I thought I could use re for this:

> re:split("123abcabc456", "(abc)+").
[<<"123">>,<<"abc">>,<<"456">>]


The manual page says the matching split string is not included in the
output - at least that what it appear to me to say.

How in the name of the great blue-eyed slimy thing that hides under stones
can I get rid of the additional <<"abc">> - this is totally not obvious to
me.

try again:

> re:split("123abcabcabc456", "abc",[notempty]).
[<<"123">>,<<>>,<<>>,<<"456">>]


I was under the vague impression that <<>> *was* and empty string

I knew I hated regular expressions, can't they be outlawed?



/Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140214/fff6fe6d/attachment.htm>


More information about the erlang-questions mailing list