R
Robert Klemme
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