<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Thanks a lot it solves my problem.<div><br></div><div><br></div><div>Thanks a lot<br><br><span class="EC_Apple-style-span" style="font-family:Tahoma"><span class="EC_Apple-style-span" style="font-size:12pt"><span class="EC_Apple-style-span" style="font-style:italic">Regards,</span></span></span><div><span class="EC_Apple-style-span" style="font-family:Tahoma"><span class="EC_Apple-style-span" style="font-size:12pt"><br></span></span></div><div><span class="EC_Apple-style-span" style="font-size:12pt"><span class="EC_Apple-style-span" style="font-weight:bold">Muhammad Yousaf</span></span></div><br><br><br><br><hr id="stopSpelling">From: dmercer@gmail.com<br>To: muhammad.yousaf@live.com; comptekki@gmail.com; erlang-questions@erlang.org<br>Subject: RE: [erlang-questions] Re: How to remove \ from string<br>Date: Thu, 7 Apr 2011 09:42:45 -0500<br><br>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML"><style>
.ExternalClass p.ecxMsoNormal, .ExternalClass li.ecxMsoNormal, .ExternalClass div.ecxMsoNormal
{margin-bottom:.0001pt;font-size:12.0pt;font-family:'Cambria','serif';}
.ExternalClass a:link, .ExternalClass span.ecxMsoHyperlink
{color:blue;text-decoration:underline;}
.ExternalClass a:visited, .ExternalClass span.ecxMsoHyperlinkFollowed
{color:purple;text-decoration:underline;}
.ExternalClass p
{margin-right:0in;margin-left:0in;font-size:12.0pt;font-family:'Cambria','serif';}
.ExternalClass span.ecxapple-style-span
{;}
.ExternalClass span.ecxecapple-style-span
{;}
.ExternalClass span.ecxEmailStyle20
{font-family:'Calibri','sans-serif';color:#1F497D;}
.ExternalClass .ecxMsoChpDefault
{font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;}
.ExternalClass div.ecxWordSection1
{page:WordSection1;}
</style><div class="ecxWordSection1"><p class="ecxMsoNormal"><b><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D">Input:</span></b><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> You have a binary with the text of an Erlang term in it:</span></p><p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> </span></p><p class="ecxMsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:Consolas;color:#1F497D">Data = <<"{get,\"user\",\"wilson\",\"lname\"}">>.</span></p><p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> </span></p><p class="ecxMsoNormal"><b><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D">Output:</span></b><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> The Erlang term represented by the binary:</span></p><p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> </span></p><p class="ecxMsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:Consolas;color:#1F497D">D = binary_to_list(Data),</span></p><p class="ecxMsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:Consolas;color:#1F497D">{ok, Tokens, _} = erl_scan:string(D ++ "."),</span></p><p class="ecxMsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:Consolas;color:#1F497D">{ok, Term} = erl_parse:parse_term(Tokens),</span></p><p class="ecxMsoNormal" style="margin-left:.5in"><span style="font-size:11.0pt;font-family:Consolas;color:#1F497D">Term.</span></p><p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> </span></p><p class="ecxMsoNormal"><span style="font-size:11.0pt;font-family:'Calibri','sans-serif';color:#1F497D"> </span></p><div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt"><div><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in"><p class="ecxMsoNormal"><b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">From:</span></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> erlang-questions-bounces@erlang.org [mailto:erlang-questions-bounces@erlang.org] <b>On Behalf Of </b>Muhammad Yousaf<br><b>Sent:</b> Wednesday, April 06, 2011 3:07 PM<br><b>To:</b> comptekki@gmail.com; erlang-questions@erlang.org<br><b>Subject:</b> [erlang-questions] Re: How to remove \ from string</span></p></div></div><p class="ecxMsoNormal"> </p><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Thank you i got your point but what i am trying to do is , remote computer is sending me a data via socket like {get,"user","wilson","lname"}</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">but for some reason i cannot match it in case statement my output is </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">im in none </span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">recieve Data from socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253,</span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> 1,255,251,3,255,253,3]</span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">im in none </span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}"</span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">im in none </span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><b><i><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">recieve Data from socket:"\r\n"</span></i></b><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Code is as fellow </span></p></div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">do_echo(Socket) -></span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> case gen_tcp:recv(Socket, 0) of</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> {ok, Data} -></span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> D = binary_to_list(Data),</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> case D of </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> {get,_,_,_} -> io:format("im innnnnnn~n");%gen_tcp:send(Socket,erl_api:search());</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> _Else -> io:format("im in none ~n")</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> end,</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> io:format("recieve Data from socket:~p~n",[D]),</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> do_echo(Socket);</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> {error, closed} -></span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> ok</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> end.</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'">Any idea what i am doing wrong ??</span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"><br></span><span class="ecxecapple-style-span"><i><span style="font-family:'Tahoma','sans-serif'">Regards,</span></i></span><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p><div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"> </span></p></div><div><p class="ecxMsoNormal"><span class="ecxecapple-style-span"><b><span style="font-family:'Tahoma','sans-serif'">Muhammad Yousaf</span></b></span><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"></span></p></div><p class="ecxMsoNormal"><span style="font-size:10.0pt;font-family:'Tahoma','sans-serif'"><br><br><br><br>> Date: Wed, 6 Apr 2011 12:44:29 -0600<br>> Subject: Re: [erlang-questions] Re: How to remove \ from string<br>> From: comptekki@gmail.com<br>> To: muhammad.yousaf@live.com<br>> CC: erlang-questions@erlang.org<br>> <br>> On Wed, Apr 6, 2011 at 11:36 AM, Muhammad Yousaf<br>> <muhammad.yousaf@live.com> wrote:<br>> ><br>> > Thanks a lot but i only want to remove backslash not double quotes<br>> > for example<br>> > Val = <<"{get,\"user\",\"wilson\",\"lname\"}">> ,<br>> > i need Val= <<"{get,"user","wilson","lname"}">><br>> > what i am doing with your help<br>> ><br>> > re:replace(Val,["\\"],"",[global, {return,list}]). getting error<br>> ><br>> > [X||X<-"{get,\"user\",\"wilson\",\"lname\"}",X=/=$\\].<br>> ><br>> <br>> <snip><br>> <br>> <br>> Another way to see what is going on is do this:<br>> <br>> Y=binary_to_list(<<"{get,\"user\",\"wilson\",\"lname\"}">>).<br>> [io_lib:format("~c~w",[X, X])||X <- Y].<br>> <br>> You'll see \" in the output, but the ascii numeric value for that<br>> character is 34.<br>> <br>> Then if you go and look and see what 34 is on the ascii table below,<br>> you'll see it is ".<br>> <br>> http://www.asciitable.com/<br>> <br>> -wes</span></p></div></div></div></div> </body>
</html>