给出一个string字符串,统计里面出现的多个字符的个数


统计任意字符串中非空格非数字字符个数
希望有一个简洁的方法


string str("1+ ds as 00 ! #");

int countCharacter(string& s) {
  int count = 0;
  for (auto &c : s) {
    if (c != ' ' && (c < '0' || c > '9')) ++count; // 非空格  非数字字符 => 计数器+1
  }
  return count;
}