I'm trying to split (variable) output restext
into individual sentences (delimiters are '.', '?' and '!' for this exercise), and print only the first sentence (i.e. take output restext
, look for first occurrence of either '.', '?' or '!' and print the first full sentence). Without the use of external libraries
I've tried
printtext = restext.replace('?',' ').replace('!',' ').replace('.',' ').split()
print(printtext);
For example:
restext = "Hello my dear! How have you been? I was wondering how you are. Do let me know how you are!"
I will get
[Hello, my, dear, How, have, you, been, I, was, wondering, how, you, are, Do, let, me, know, how, you, are]
But I'm looking for
"Hello my dear!"