From: Jean-Julien Fleck Date: 2010-03-28T01:59:19+09:00 Subject: Re: remove overall indentation preserving reletive indentation Hello Jesse, > I assume the solution would probably involve getting the number of > spaces for the first line and removing that number of spaces from each > line in the block? You are also assuming your text is consistently indented from the first line, that is you don't have ....line 1 ..line 2 ....line 3 for example. A better way would be (I think) to check first each line to search for the minimum number of spaces and then remove that number of spaces from each line (assuming also that you have normal spaces and no tabulations for example). One way would be string = " line1\n line2\n line3" puts string arr = string.split(/\n/) nb = arr.collect {|line| line =~ /^( *)/ ; $1.length}.min new_string = arr.collect {|line| line.sub(/ {#{nb}}/,'')}.join("\n") puts new_string Cheers, -- JJ Fleck PCSI1 Lycée Kléber