From: moontoeki@... (Sung Moon) Date: 2002-02-04T21:37:44+09:00 Subject: Re: range and modification >Subject: Re: range and modification >From: matz@ruby-lang.org (Yukihiro Matsumoto) > >Hi, > >|So, we can use chomp for the line ending with \n, >|but we can not use either chop or chomp for line ending with \r\n. > >1.7.2 chomp works as you want. > > matz. I would like to summarize for others ["jeff\n", "japhy"].each{|str| puts "<#{ str.chomp.inspect }>"} # ==> <"jeff"> <"japhy"> It's OK ["jeff\n", "japhy"].each{|str| puts "<#{ str.chop.inspect }>"} # ==> <"jeff"> <"japh"> It's not OK ["jeff\r\n", "japhy"].each{|str| puts "<#{ str.chomp.inspect }>"} # ==> <"jeff\r"> <"japhy"> It's not OK ["jeff\r\n", "japhy"].each{|str| puts "<#{ str.chop.inspect }>"} # ==> <"jeff"> <"japh"> It's not OK ["jeff\r\n", "japhy"].each{|str| puts "<#{ str.chomp(\"\r\n\").inspect }>"} # ==> <"jeff"> <"japhy"> It's OK So, we can use chomp for the line ending with \n, but with the ending \r\n, we have to use chomp with \r\n parameter matz told 1.7.2 chomp works for both cases thanks sungjin moon