diff -r 558b26b6a342 Lib/textwrap.py --- a/Lib/textwrap.py Sun Feb 02 12:50:48 2014 -0500 +++ b/Lib/textwrap.py Sun Feb 02 22:31:51 2014 +0200 @@ -79,16 +79,17 @@ # 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+[^0-9\W]-(?=\w+[^0-9\W])|' # hyphenated words - r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash + wordsep_re = re.compile(( + r'([{0}]+|' # any whitespace + r'[^{0}\w]*\w+[^0-9\W]-(?=\w+[^0-9\W])|' # hyphenated words + r'(?<=[\w\!\"\'\&\.\,\?])-{{2,}}(?=\w))' # em-dash + ).format(_whitespace)) # This less funky little regex just split on recognized spaces. E.g. # "Hello there -- you goof-ball, use the -b option!" # splits into # Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/ - wordsep_simple_re = re.compile(r'(\s+)') + wordsep_simple_re = re.compile(r'([{}]+)'.format(_whitespace)) # XXX this is not locale- or charset-aware -- string.lowercase # is US-ASCII only (and therefore English-only)