diff options
author | Greg Ward <gward@python.net> | 2005-03-05 02:53:17 +0000 |
---|---|---|
committer | Greg Ward <gward@python.net> | 2005-03-05 02:53:17 +0000 |
commit | 1cbcbb2ac99090b597f6e9446c557607208cb483 (patch) | |
tree | f03a8362570c65e3c9ae3552c41b5846b623cbc6 /Lib/textwrap.py | |
parent | 9743f6bf8d01e41236c4f6bc3540e4e022512cd6 (diff) | |
download | cpython-1cbcbb2ac99090b597f6e9446c557607208cb483.tar.gz |
SF #1149508: ensure textwrap handles hyphenated numbers correctly,
eg. "2004-03-04" is not broken across lines. (Merged from 2.4 branch.)
Diffstat (limited to 'Lib/textwrap.py')
-rw-r--r-- | Lib/textwrap.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/textwrap.py b/Lib/textwrap.py index 8e3d8cf594..4576ef2a3f 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -78,9 +78,10 @@ class TextWrapper: # splits into # 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'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash + wordsep_re = re.compile( + r'(\s+|' # any whitespace + 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 # is US-ASCII only (and therefore English-only) |