From: "Jesús Gabriel y Galán" Date: 2010-10-04T17:13:25+09:00 Subject: Re: save only first line from string? On Mon, Oct 4, 2010 at 4:19 AM, 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.) irb(main):004:0> a = "abcde\nfghwrferf\nqwerim1o34ir1" => "abcde\nfghwrferf\nqwerim1o34ir1" irb(main):005:0> a.first => "abcde\n" irb(main):006:0> a.first.chomp => "abcde" Jesus.