this regular expression will replace an instance of 1 or more white spaces with 1 space, ps \s will replace all space characters that include \s\t\r\n\f :
a_string.gsub!(/\s+/, ' ')
Similarly for carriage return only
str.gsub!(/\n/, " ")
Replace all \n with a space first, then use removing multiple space.
Ali Aug 18 '11 at 11:56 2011-08-18 11:56
source share