To re or not to re ... ( word wrap function?)

Chris Barker chrishbarker at home.net
Mon Sep 24 14:44:25 EDT 2001


Thanks to all of you who posted code: I've learned something from each
one.


I did notice that no one used an re-based solution, except Skip using

re.split(r'\s+', s)

Is this any different than string.split(s) ?

Note that I didn't want to use either of these, as they would kill any
sequences of whitespace, such as two spaces after a sentence.


tex_wrap looks very nice but is really overkill for this application.


I also noticed that no one took my approach, which was to start at the
end of the line and work backwards looking for space. You all took the
approach of building the new line word by word from the beginning.

hmmmm.

-Chris


-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------




More information about the Python-list mailing list