Posted By

ndegruchy on 07/06/06


Tagged

textmate python regexp text console


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

ndegruchy
Kobold
anayhk
taboularasa


Wrap Text to Eighty Columns


 / Published in: Python
 

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

  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  

You need to login to post a comment.