From: William James Date: 2006-12-28T18:00:14+09:00 Subject: Re: Strip is not stripping trailing whitespace Taylor Strait wrote: > > It couldn't have. > > > > strip removes newlines, because they are whitespace. > > On the other hand, neither chomp nor strip removes "\240". > > > >>> "foo \n".strip > > => "foo" > >>> ("foo " + 0240.chr).chomp > > => "foo \240" > > This is why I shouldn't code at 3:30am! I had used chop instead, which > of course truncated the text in rare cases. How can I remove \240? > > -- > Posted via http://www.ruby-forum.com/. Remove ASCII 128-- 255 at end of line: irb(main):016:0> "foo\240\250 \n".strip. irb(main):017:0* sub(/[#{128.chr}-#{255.chr}]+$/,"") => "foo"