Is there any equivalent to str.split
in Python that also returns the delimiters?
I need to preserve the whitespace layout for my output after processing some of the tokens.
Example:
>>> s=" this is an example"
>>> print s.split()
[ this , is , an , example ]
>>> print what_I_want(s)
[ , this , , is , , an , , example ]
Thanks!