[erlang-questions] re:split not splitting at pipe symbol

Andrey Pampukha andrey.pampukha@REDACTED
Sat Jan 8 19:59:11 CET 2011


I thought, string:tokens/2 is enough for such purpose :)
(main@REDACTED)1> string:tokens("123|456","|").
["123","456"]

Andrey.

2011/1/8, Alain O'Dea <alain.odea@REDACTED>:
> On 2011-01-08, at 11:02, Dirk Scharff <dirk.scharff@REDACTED> wrote:
>
>> Hi all!
>>
>> I'm experiencing a problem with re:split/2 which doesn't seem to be able
>> to split at a pipe symbol "|". Is there a reason for this or is this a
>> bug?
>>
>> Reproduce as follows:
>> 1> re:split("123|456","|").
>
> Pipe is a meaningful symbol in regular expressions. It means 'or'.  You need
> to escape the pipe:
>
>     re:split("123|456","\\|").
>
>> [<<"1">>,<<"2">>,<<"3">>,<<"|">>,<<"4">>,<<"5">>,<<"6">>,
>> <<>>]
>> 2> re:split("123|456",[124]).
>> [<<"1">>,<<"2">>,<<"3">>,<<"|">>,<<"4">>,<<"5">>,<<"6">>,
>> <<>>]
>> 3> regexp:split("123|456","|").
>> {ok,["123","456"]}
>>
>> Regards,
>> Dirk.
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list