I need to capitalize first character of a sentence where sentence ends with a period. ( it could be multiple periods too) OR !
String result = "";
Scanner scanner = new Scanner(content);
scanner.useDelimiter("(?<=(\\.+))|(?<=!)");
while (scanner.hasNext()) {
String line = scanner.next();
String line1 = line.substring(0, 1).toUpperCase() + line.substring(1);
result = result + line1;
}
When i do this , the whitespace new line character is present at the 0 index and the program doesn't capitalize the letter.