[erlang-questions] string:strip/3 don't work right striping

Gustav Simonsson <>
Wed Jan 19 08:57:11 CET 2011


string:strip(string:to_lower("....Hello...."), both, $.).
will evaluate to "hello". The reason you received dots in your
shell might be because you print out the raw Data after you print
out ReParseData, without anything printed between.

Best Regards,
Gustav Simonsson

----- Original Message -----
From: "shk" <>
To: 
Sent: Wednesday, 19 January, 2011 07:48:54 GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: [erlang-questions] string:strip/3 don't work right striping


Hello,

I receive data by socket in tcp:

receive_loop(Socket) ->
    case gen_tcp:recv(Socket, 0) of
	 {ok, Data} ->
	    ReParseData = string:strip(string:to_lower(Data), both, $.),
	    io:format(ReParseData, []),
	    case ReParseData of
		"quit\r\n" ->
	          gen_tcp:send(Socket, "quit \r\n"),
		  gen_tcp:close(Socket);
	        _ ->
		  io:format(Data, []),
		  receive_loop(Socket)
	     end;
	 {error, closed} ->
	    ok
    end.

if I send .........................Hello
......................................
I got in shell:
>Hello ......................................

How can i correctly delete space from left and right in stirng?

Thank you.
-- 
View this message in context: http://erlang.2086793.n4.nabble.com/string-strip-3-don-t-work-right-striping-tp3224632p3224632.html
Sent from the Erlang Questions mailing list archive at Nabble.com.

________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:



More information about the erlang-questions mailing list