Andreas Schwarz wrote: > It doesn't work correctly, I have to think about it again... OK, now this finally seems to work: def wrap(a, max_len) s = a.gsub(/.{0,#{max_len}}(?:\s|\Z)/){($& + 5.chr).gsub(/\n\005/,"\n")} while(s.sub!(/((\n|^)[>|\s]*[>|].*?)\005/, "\\1")) do end return s.gsub(/\005/,"\n") end I don't think it is a very good solution, so if someone comes up with a better one I would really like to see it. Andreas -- AVR-Tutorial, er 350 Links Forum f AVRGCC und MSPGCC -> http://www.mikrocontroller.net