R
Robert Oschler
Hello,
Given the following program:
--------------
import re
x = "The dog ran. The cat eats! The bird flies? Done."
l = re.split("[.?!]", x)
for s in l:
print s.strip()
# for
---------------
I am getting the following output:
The dog ran
The cat eats
The bird flies
Done
As you can see the end of sentence punctuation marks are being removed. Yet
the the docs for re.split() say that the matched text is supposed to be
returned. I want to keep the punctuation marks.
Where am I going wrong here?
Thanks,
Given the following program:
--------------
import re
x = "The dog ran. The cat eats! The bird flies? Done."
l = re.split("[.?!]", x)
for s in l:
print s.strip()
# for
---------------
I am getting the following output:
The dog ran
The cat eats
The bird flies
Done
As you can see the end of sentence punctuation marks are being removed. Yet
the the docs for re.split() say that the matched text is supposed to be
returned. I want to keep the punctuation marks.
Where am I going wrong here?
Thanks,