DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Wrap Text In Ruby
Posted by Allen Odgaard to
http://macromates.com/blog/archives/2006/06/28/wrapping-text-with-regular-expressions/
def wrap_text(txt, col = 80)
txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n")
end





