[erlang-questions] Stripping slashes from a string

Michael Turner michael.eugene.turner@REDACTED
Fri Apr 27 08:34:20 CEST 2012


Works for me, Martin. Maybe you need to write the result with ~s
rather than ~p? E.g.

   io:format ("~s", R2);

Made that mistake myself ....

-michael turner


On Fri, Apr 27, 2012 at 2:17 PM, Martin Dimitrov <mrtndimitrov@REDACTED> wrote:
> Hello,
>
> I have a string as the following:
>
> "This is some\\r\\ntext"
>
> I am trying to replace "\\r" with \r and "\\n" with \n.
>
> I do it with the following two reg expressions:
>
> R1 = re:replace(Result, "\\\\r", "\\\r", [{return,list}, global, unicode]),
> R2 = re:replace(R1, "\\\\n", "\\\n", [{return,list}, global, unicode]),
>
> Is there a better way? I tried to combine the two regex like:
>
> re:replace(Result, "\\\\(r|n)", "\\\\1", [{return,list}, global, unicode])
>
> but can't make it to work.
>
> Thanks for looking at this.
>
> Best regards,
>
> Martin
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list