And if you want to replace all the newlines in some text, you can use gsub(): str =<<ENDOFSTRING 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/.