例如: “aaa 888 a88 a uus88,ss”
纯字母串为:3
纯数字串为:1
其它串为:2
public class Test04 { public static void main(String[] args) { // TODO Auto-generated method stub String s = "aaa 888 a88 a uus88,ss"; String[] arr = s.split("[ ,]"); int a=0,b=0,c=0; for (String str : arr) { if(str.matches("[a-zA-Z]{1,}")) { a++; }else if(str.matches("[0-9]{1,}")) { b++; }else{ c++; } } System.out.println(a + "," + b + "," + c); } }