/ Published in: Ruby
URL: http://blog.macromates.com/2006/wrapping-text-with-regular-expressions/
Hat tip: Allan Odgaard
Expand |
Embed | Plain Text
def wrap_text(txt, col = 80) txt.gsub(/(.{1,#{col}})( +|$)\n?|(.{#{col}})/, "\\1\\3\n") end
You need to login to post a comment.
