解决方案可能是在点的情况下,您可以检查后面是否有空格和大写字母。“[点][空格][大写字母]”这将是对判决的肯定更新相同的代码:public static void main( String args[] ) { // String to be scanned to find the pattern. String line = "This order was placed for QT3000! MK? \n Thats amazing. \n But I am not sure."; String pattern = "([.!?])([\\s\\n])([A-Z]*)"; // Create a Pattern object Pattern r = Pattern.compile(pattern); // Now create matcher object. Matcher m = r.matcher(line); int count=0; while (m.find( )) { count++; } count++; //for the last line, which will not get included here. System.out.println("COUNT=="+count);}