Hi,<br><br>If you quote the '&' character with \ then you will get a & in the out put string. So<br><br>Str1 = "String with \\& character"<br><br>N.B. you need an extra \ because it is in a string and the string parsing converts \\ into \ in the resultant string.<br>
<br>Robert<br><br><div><span class="gmail_quote">On 15/03/2008, <b class="gmail_sendername">shehan</b> <<a href="mailto:shehan@wavenet.lk">shehan@wavenet.lk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Hi all,</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Is the some way to stop the following behaviour of the
"sub" function in the "regexp" module</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Str1 = "String with & character"</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Str2 = "Replace the following tag <replace> with
str1"</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">regexp:sub(Str2, "<replace>", Str1).</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">{ok, NewStr, Count} = regexp:gsub(Str1,
["<ad2>"], Ad2). </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">NewStr.</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">"Replace the following tag String with <replace>
character with str1"</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">The <replace> is replaced by the content of Str1, but
the & character in Str1 has been replaced by the </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">replaced character set <replace>. is there some way to
stop this from happening.</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;"> </span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Thanx</span></font></p>

<p><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">Shehan</span></font></p>

</div>

</div>


<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></blockquote></div><br>