question about the textwrap module

Sion Arrowsmith siona at chiark.greenend.org.uk
Wed Oct 29 08:00:50 EDT 2008


Gabriel Genellina <gagsl-py2 at yahoo.com.ar> wrote:
>py> text = 'This          is some \t   text with  multiple\n\n  spaces.'
>py> import re
>py> re.sub(r'\s+', ' ', text)
>'This is some text with multiple spaces.'

py> ' '.join(text.split())
'This is some text with multiple spaces.'

-- 
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
   "Frankly I have no feelings towards penguins one way or the other"
        -- Arthur C. Clarke
   her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump



More information about the Python-list mailing list