Wrap Text to Eighty Columns


/ Published in: Python
Save to your folder(s)

warning: snipplr tends to escape the quotes and slashes, causing this snippet to fail when pasted verbatim.


Copy this code and paste it in your HTML
  1. def wrap_text(txt, col = 80):
  2. import re
  3. re.sub("/(.{1,#{col}})( +|$n?)|(.{1,#{col}})/", "\1\3n", txt)
  4. # warning: snipplr tends to escape the quotes and slashes, causing this
  5. # snippet to fail when pasted in.
  6. return txt

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.