From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-06-27T23:06:48+09:00 Subject: Re: \s in regex On Fri, 27 Jun 2003 07:36:35 +0000, s moon wrote: > 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. How about String#strip! ? # untested :-) ifile.each { |line| ofile.print line.strip! } -- Simon Strandgaard