[erlang-questions] Re: How to remove \ from string
Wes James
comptekki@REDACTED
Wed Apr 6 23:01:45 CEST 2011
On Wed, Apr 6, 2011 at 2:07 PM, Muhammad Yousaf
<muhammad.yousaf@REDACTED> wrote:
>
> 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"}
> but for some reason i cannot match it in case statement my output is
> im in none
> recieve Data from
> socket:[255,251,31,255,251,32,255,251,24,255,251,39,255,253,
> 1,255,251,3,255,253,3]
> im in none
> recieve Data from socket:"{get,\"user\",\"wilson\",\"lname\"}"
> im in none
> recieve Data from socket:"\r\n"
>
> Code is as fellow
> do_echo(Socket) ->
> case gen_tcp:recv(Socket, 0) of
> {ok, Data} ->
> D = binary_to_list(Data),
> case D of
> {get,_,_,_} -> io:format("im
> innnnnnn~n");%gen_tcp:send(Socket,erl_api:search());
> _Else -> io:format("im in none ~n")
> end,
> io:format("recieve Data from socket:~p~n",[D]),
<snipt>
Or you could use something like this:
...
D = binary_to_list(Data),
case D of
"{get"++_ -> io:format("im innnnnnn~n");
...
using matching.
-wes
More information about the erlang-questions
mailing list