I need to split strings of data using each character from string.punctuation and string.whitespace as a separator.

Furthermore, I need for the separators to remain in the output list, in between the items they separated in the string.

For example,

"Now is the winter of our discontent"

should output:

['Now', ' ', 'is', ' ', 'the', ' ', 'winter', ' ', 'of', ' ', 'our', ' ', 'discontent']

I'm not sure how to do this without resorting to an orgy of nested loops, which is unacceptably slow. How can I do it?

Edit
Report