题解 | #统计字符#
统计字符
http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String input = scan.nextLine();
String str1 = input.replaceAll("[^a-zA-Z]","");
String str2 = input.replaceAll("[^ ]","");
String str3 = input.replaceAll("[^0-9]","");
String str4 = input.replaceAll("[a-zA-Z0-9 ]","");
System.out.println(str1.length());
System.out.println(str2.length());
System.out.println(str3.length());
System.out.println(str4.length());
}
}
}