fork download
  1. import java.util.Scanner;
  2. import java.util.regex.*;
  3.  
  4. public class Main
  5. {
  6. public static void main (String[] args)
  7. {
  8. String string;
  9. int sentenceCount = 0;
  10. Pattern pattern = Pattern.compile("[.!?]+");
  11. Matcher matcher;
  12. Scanner scanner = new Scanner(System.in);
  13.  
  14. string = scanner.nextLine();
  15. matcher = pattern.matcher(string);
  16.  
  17. while (matcher.find()) sentenceCount++;
  18.  
  19. System.out.println(sentenceCount);
  20. }
  21. }
Success #stdin #stdout 0.06s 4386816KB
stdin
Do not fall in love with programming languages
stdout
0