Return to Snippet

Revision: 6337
at May 16, 2008 17:12 by breakerjump


Initial Code
def wrap_text(txt, col = 80)
  txt.gsub(/(.{1,#{col}})( +|$)\n?|(.{#{col}})/,
    "\\1\\3\n")
end

Initial URL
http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/

Initial Description
Hat tip: Allan Odgaard

Initial Title
Text Wrapping with Regular Expressions

Initial Tags
text

Initial Language
Ruby