题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
	正则表达式解法 完整代码如下:
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
    // Write your code here
    while(line = await readline()){
        console.log(line.match(/[a-zA-Z]/g) ? line.match(/[a-zA-Z]/g).length : 0);
        console.log(line.match(/\s/g) ? line.match(/\s/g).length : 0);
        console.log(line.match(/\d/g) ? line.match(/\d/g).length : 0);
        console.log(line.match(/[^a-zA-Z\s\d]/g) ? line.match(/[^a-zA-Z\s\d]/g).length : 0);
    }
}()
 查看9道真题和解析
查看9道真题和解析
 智元机器人成长空间 174人发布
智元机器人成长空间 174人发布