[erlang-questions] re:split not splitting at pipe symbol
Alain O'Dea
alain.odea@REDACTED
Sat Jan 8 15:58:21 CET 2011
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
>
More information about the erlang-questions
mailing list