From: internetletter@... (s moon) Date: 2003-06-27T22:46:35+09:00 Subject: \s in regex what I want is to remove beginning and trailing spaces from lines. this is a failed try. ifile.each { | line | ofile.print line.sub(/^\s+/,"").sub(/\s+$/,"") } this removes spaces from begin and end of lines but it also removes blank lines. it seems \s matches \r or \n also. this is another one, this time it works. ifile.each { | line | if line =~ /^\s*$/ # take care of blank lines ofile.print line else ofile.print line.sub(/^\s+/,"").sub(/\s+$/,"") end } but can i do this with one line without if-then-else? thanks