python regex inserting a space between punctuation and letters

Viewed 7091

I assume the best way to do this is with regex but I do not know how to do it. I am trying to parse a string and put a space between letters and punctuation only. I want to keep punctuation marks together. As an example if I have the string

"yes!!!"

I want to end up with

"yes", "!!!".

If I have the string

!!!N00bs,

I want to end up with

"!!!", "N00bs"

Is this possible? What is the best way to do this? Right now I am parsing each letter and it a silly way of doing it.

Thanks for the help.

3 Answers
Related