From: Benoit Daloze Date: 2010-10-05T02:38:15+09:00 Subject: Re: save only first line from string? On 4 October 2010 04:19, Terry Michaels wrote: > Hi. What's the most simple and elegant way to remove all the contents of > a String except for the first line? (Assume string consist of one line, > multiple lines, or no lines, and assume that we don't know which OS we > are on.) > -- Probably the most elegant, with Ruby 1.9: str = str.lines.first add ".chomp" if you want to remove the trailing EOL.