From: Brian Candler Date: 2010-08-03T22:11:43+09:00 Subject: Re: How to remove leading   from string Lucky Nl wrote: > But if i gave with littile modifiaction at endof line is enetered with > chars

dada  ddsa

" > > str giving result nil Yes, the result of gsub! is nil if no change is made; but the string remains as it was. irb(main):001:0> str = "abc" => "abc" irb(main):002:0> str.gsub!(/d/,"") => nil irb(main):003:0> str => "abc" It's intended so you can say if str.gsub! ... # it changed else # it didn't end If you use gsub instead of gsub!, then it always returns the resulting string. irb(main):004:0> str2 = str.gsub(/d/,"") => "abc" -- Posted via http://www.ruby-forum.com/.