On Mon, Oct 4, 2010 at 4:19 AM, Terry Michaels <spare / frigidcode.com> 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):005:0> s = "multiple\nlines\n"
=> "multiple\nlines\n"
irb(main):006:0> s[/^.*$/]
=> "multiple"
irb(main):007:0> s[/^.*?$/]
=> "multiple"

Cheers

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/