用java统计字符串中中文,英文,数字各多少个!
public class CountCharacter {
public static void main(String[] args) {
String str = "哈回家看电视hello1234567890";
int length = str.length();
int nLen = length - str.replaceAll("\\d", "").length();
int eLen = length - str.replaceAll("[a-zA-Z]", "").length();
int cLen = length - nLen - eLen;
System.out.println("num:"+nLen);
System.out.println("english:"+eLen);
System.out.println("chinese:"+cLen);
}
}