I am attempting to write code to remove a whole sentence from a paragraph. It doesn't matter which sentence it is, but it needs to be at least one.
String edit = "The cow goes moo. The cow goes boo. The cow goes roo. The cow goes jew.";
int sentencestart = (edit.substring(edit.length()/2).indexOf('.') + edit.length()/2);
int sentenceend = edit.substring(sentencestart).indexOf('.') + sentencestart;
edit = edit.substring(0, sentencestart) + edit.substring(sentenceend);
System.out.println(edit);
This is the code I currently have. It is currently printing the exact same string that I begin with. Any one have any ideas?
EDIT: I was wrong to imply that any sentence should be removed. I meant any sentence aside from the first. Preferably the sentence to be removed would fall somewhere within the middle of the string, and the actual application would be used in very large strings.