I have a string like
x = 'Test. Test1. Test test test.'
Now I would like to separate the last sentence (meaning the last set of strings that start with a capital letter) from the rest of the strings in a list. How’s that possible?
>Solution :
You can use the regex [A-Z][^A-Z]*$ to fetch that.
Example:
import re
s='Test. Test1. Test test test.'
last_sentence=re.findall('[A-Z][^A-Z]*$',s)
print(last_sentence)
Output:
['Test test test.']