It is little bit difficult. In regexp you have to escape backslash and secondary must escape backslash for erlang parser but for substituting string you have to only escape for erlang parser. Weird, so ...<br><br>5> {ok, T, _} = regexp:gsub("qwert\\asdf", "\\\\", "\\\\").<br>
{ok,"qwert\\\\asdf",1}<br>6> io:format("~s~n", [T]).<br>qwert\\asdf<br>ok<br><br><br><div class="gmail_quote">2008/6/25 Andrey Shnayder <<a href="mailto:camuig@gmail.com">camuig@gmail.com</a>>:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi, Erlang team.<br>I want to add slashes before some characters in a string - single quote, double quote, backslash.<br>
I have not found any function that implement this, therefore I use regexp:gsub function, but I have a trouble with backslashes:<br>
<br><i>69> regexp:gsub("qwert\\asdf", "\\", "\\\\").<br>{error,{unterminated,"\\"}}</i><br><br>May you help me, please?<br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil