Return to Snippet

Revision: 250
at July 6, 2006 13:05 by ndegruchy


Updated Code
def wrap_text(txt, col = 80):
    import re
    re.sub("/(.{1,#{col}})( +|$n?)|(.{1,#{col}})/", "\1\3n", txt)
    # warning: snipplr tends to escape the quotes and slashes, causing this
    # snippet to fail when pasted in.
    return txt

Revision: 249
at July 6, 2006 11:23 by ndegruchy


Initial Code
def wrap_text(txt, col = 80):
    import re
    re.sub(\"/(.{1,#{col}})( +|$n?)|(.{1,#{col}})/\", \"\\1\\3n\", txt)
    return txt

Initial URL

                                

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

Initial Title
Wrap Text to Eighty Columns

Initial Tags
textmate, python, regexp, text

Initial Language
Python