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