From: Chris Kottom Date: 2011-03-26T16:05:10+09:00 Subject: Re: How to "find" new lines --90e6ba53a5dead12e7049f5d5483 Content-Type: text/plain; charset=UTF-8 7stud is right. I missed the important word "only" in your original email. My original method will produce false positives if you are indeed interested in finding strings which are only "\n". The "==" method works fine. Regexp is also possible (though probably slower) if done as: if str =~ /^\n$/ On Sat, Mar 26, 2011 at 3:43 AM, 7stud -- wrote: > And if you want to replace all the newlines in some text, you can use > gsub(): > > str =< hello world > goodbye > hi again world > ENDOFSTRING > > > result = str.gsub(/\n/, ' ') > puts result > > --output:-- > hello world goodbye hi again world > > -- > Posted via http://www.ruby-forum.com/. > > --90e6ba53a5dead12e7049f5d5483--