I'm trying to build up a regular expression which splits a paragraph in sentences separated by a period (.
). That should work:
String str[] = text.split("\\.");
However I'd need to add a minimum of robustness, for example checking that the period is followed by a space
and an uppercase letter.
So here's my next guess:
String text="The pen is on the table. The table has a pen upon it.";
String arr[] = text.split("\\. [A-Z]");
for (String s: arr)
System.out.println(s);
Output:
The pen is on the table
he table has a pen upon it.
Unfortunately, I'm missing the first character after the period. Can you see any way it can be fixed?