irb(main):002:0> "123456789 TCP/XT OK".gsub(/TCP\/XT OK/,nil) =>"123456789 " Works for me. Ralph ----- Original Message ----- From: "Paul Vallance" <paulvallance / wanadoo.nl> To: "ruby-talk ML" <ruby-talk / ruby-lang.org>; <undisclosed-recipients:> Sent: Saturday, December 29, 2001 12:35 PM Subject: [ruby-talk:29602] Stripping substrings from strings > Newsgroups: comp.lang.ruby > Organization: http://groups.google.com/ > NNTP-Posting-Host: 194.134.217.33 > X-Trace: posting.google.com 1009581565 27944 127.0.0.1 (28 Dec 2001 23:19:25 GMT) > X-Complaints-To: groups-abuse / google.com > NNTP-Posting-Date: 28 Dec 2001 23:19:25 GMT > X-rubymirror: yes > Content-Type: text/plain; charset=ISO-8859-1 > Content-Transfer-Encoding: 8bit > Precedence: bulk > Lines: 28 > Sender: ruby-talk-admin / ruby-lang.org > > Dear ruby gurus, > > I would like to put the string returned via the TCP Server to my > rubyscript into a variable (@readdata) and strip the words "TCP/XT > OK" from the end of it and update the variable, then use the contents > of this variable in a following send... something like below... . I > thought str.gsub would do it, ie replace the substring "TCP/XT OK" > with an empty string (though I'm sure "" is not right syntax for an > empty string). > > > #!/usr/bin/env ruby > > require 'socket' > t = TCPSocket.new("192.168.0.178",13) > > t.send("/firstbox\n",0) > @readdata = t.recv(30) > puts @readdata // which is "123456789 TCP/XT OK" > v = @readdata > v.str.gsub!(TCP//XT OK,"" ) > t.send("/ispicbox(#v )\n",0) > > hope someone can help, > > regards > > Paul >