Issue 1149508: textwrap wordsep_re - Python tracker

The following patch makes textwrap not consider strings
of numbers with dashes to be wrappable hyphenated words.

For example, this code:
    print textwrap.fill('aaaaaaaaaa 2005-02-21', 18)
previously produces:
    aaaaaaaaaa 2005-
    02-21

but with patch:
    aaaaaaaaaa
    2005-02-21


--- /usr/lib/python2.4/textwrap.py	2005-02-09
04:02:11.000000000 -0800
+++ /tmp/textwrap.py	2005-02-22 17:07:19.000000000 -0800
@@ -79,7 +79,7 @@
     #   Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/
/the/ /-b/ /option!
     # (after stripping out empty strings).
     wordsep_re = re.compile(r'(\s+|'                 
# any whitespace
-                           
r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words
+                           
r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|' # hyphenated words
                            
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))')   # em-dash
 
     # XXX this is not locale- or charset-aware --
string.lowercase