From: Daniel Lucraft Date: 2007-09-19T20:42:28+09:00 Subject: Re: Indenting strings - elegant alternatives? Ronald Fischer wrote: > > Given a string of lines (for example, "abc\nde\nfgh\n") and a number n, > produce a string of the same lines, but each line indented by n spaces. > This would be my first inclination: " "*n + s.gsub("\n", "\n"+" "*n) BTW, I don't think yours handles "abc\n\ndef" as you might hope... best, Dan -- Posted via http://www.ruby-forum.com/.