Possible Duplicate:
Python split() without removing the delimiter
I wish to split a string as follows:
text = " T?e qu!ck ' brown 1 fox! jumps-.ver. the 'lazy' doG? !"
result -> (" T?e qu!ck ' brown 1 fox!", "jumps-.ver.", "the 'lazy' doG?", "!")
So basically I want to split at ". "
, "! "
or "? "
but I want the spaces at the split points to be removed but not the dot, comma or question-mark.
How can I do this in an efficient way?
The str split function takes only on separator. I wonder is the best solution to split on all spaces and then find those that end with dot, comma or question-mark when constructing the required result.