I want to split a sentence with "." and "?" .You can the Actual output needed column but when ever I'm using regex or .split("//.") but i'm getting error because it also splitting after Mr. but it's not the end period. How to include only end period means when the actual sentence stop
public class SentenceSplitting {
public static void main(String[] args){
Scanner ss= new Scanner(System.in);
System.out.println("Enter the string");
String sentence= ss.nextLine();
String[] hold= sentence.split("(?<=[.!?]) (?=[^.!?])");
for(int i=0;i<hold.length;i++){
System.out.println(hold[i]);
}
}
}
Output
Mr.
Smith bought cheapsite.com for 1.5 million dollars, i.e.
he paid a lot for it.
Did he mind?
Adam Jones Jr.
thinks he didn't.
In any case, this isn't true...
Well, with a probability of .9 it isn't.
The result should be:
The Actual Output Needed
Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot for it.
Did he mind?
Adam Jones Jr. thinks he didn't.
In any case, this isn't true...
Well, with a probability of .9 it isn't.
Input
Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this isn't true... Well, with a probability of .9 it isn't. The result should be: