import re
p = re.compile(r"([?.;])")
ss = re.split(p, 'This is a test? This is a test?good.bad')
for s in ss:
print(s)
The result is:
This is a test
?
This is a test
?
good
.
bad
I hope the result would be:
This is a test?
This is a test?
good.
bad
Why does it put the delimiter on another line?
EDIT: I think I understand why it did that. The question is how to produce the result I want.