condense whitespace to single space?

Andres Corrada andres at corrada.com
Wed Apr 26 22:08:00 EDT 2000


k wrote:
> 
> How do I condense the sections of spaces in this string:
> 
> "abc              def         ghi"
> 
> into single spaces?
> 
> "abc def ghi"

One way to do this that avoids using regular expressions is:

stringParts = string.split( stringToSplit )
reconstitutedString = string.join( stringParts )
-- 
------------------------------------------------------
Andres Corrada-Emmanuel   Email: andres at corrada.com
------------------------------------------------------




More information about the Python-list mailing list