From: Mike Durham Date: 2006-09-15T08:00:49+09:00 Subject: Re: Need help about Ruby with text file Paul Lutus wrote: > Oscar Lok wrote: > >> Hi, everybody >> >> This is my first time get into this forum. >> I would like to know that is it a forum for us to discuss about >> everythings in Ruby, please? >> If so, >> 1)I would like to know that how can I delete or remove a line in a text >> file, please? >> 2)How can I read some letter in a line, please? >> e.g. a text file like this:- >> >> aabbcc >> ddeeff >> gghhii >> jjkkll >> >> 1)I want to delete ddeeff become like this:- >> aabbcc >> gghhii >> jjkkll > > -------------------------------------------------- > > #!/usr/bin/ruby > > data=< aabbcc > ddeeff > gghhii > jjkkll > EOF > > puts "Before:",data > > data.sub!(/ddeeff\n/,"") > > puts "\nAfter:",data > > -------------------------------------------------- > > Output: > > Before: > aabbcc > ddeeff > gghhii > jjkkll > > After: > aabbcc > gghhii > jjkkll > > >> 2)I get the result like :- >> hh > > Please explain the circumstances under which you want to get this result. > He said the text is "in a file" Cheers