题解 | #判断各类型字符个数#
判断各类型字符个数
https://www.nowcoder.com/practice/4ccc155e474e4d4c83cfde116dcf2218
//总字符个数
int totalLen = str.length();
//英文字母个数
words = totalLen - str.replaceAll("[a-zA-Z]", "").length();
//数字个数
numbers = totalLen - str.replaceAll("[0-9]", "").length();
//空格个数
space = totalLen - str.replaceAll("[\\s]", "").length();
//其他字符的个数
other = totalLen - words - numbers - space;
int totalLen = str.length();
//英文字母个数
words = totalLen - str.replaceAll("[a-zA-Z]", "").length();
//数字个数
numbers = totalLen - str.replaceAll("[0-9]", "").length();
//空格个数
space = totalLen - str.replaceAll("[\\s]", "").length();
//其他字符的个数
other = totalLen - words - numbers - space;