Help with splitting
RickMuller
rpmuller at gmail.com
Fri Apr 1 17:20:51 EST 2005
I'm trying to split a string into pieces on whitespace, but I want to
save the whitespace characters rather than discarding them.
For example, I want to split the string '1 2' into ['1',' ','2'].
I was certain that there was a way to do this using the standard string
functions, but I just spent some time poring over the documentation
without finding anything.
There's a chance I was instead thinking of something in the re module,
but I also spent some time there without luck. Could someone point me
to the right function, if it exists?
Thanks in advance.
R.
More information about the Python-list
mailing list