From: Brian Candler Date: 2010-04-13T20:58:12+09:00 Subject: Re: how to delete the first two characters of each row? Pen Ttt wrote: > how to delete the first two characters of each row? > i want to delete the first two characters of each row in file > /home/pt/test/mtp.txt > > > io=open("/home/pt/test/mtp.txt","r") > io1=open("/home/pt/test/mtpback.txt","w") > while line=io.gets > ioput=line.delete("/^..../") You are trying to delete exactly the string of characters "/^..../" You need to match against a regular expression instead. For example, ioput=line.sub(/^..../, '') (That will delete the first 4 characters in each line, but only if there are 4 or more) -- Posted via http://www.ruby-forum.com/.