题解 | #统计字符#

统计字符

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);
    }
}()


全部评论

相关推荐

明天不下雨了:兄弟你是我今天看到的最好看的简历(我说的是简历风格跟简历书写)把985 211再搞亮一点。投boss就说;您好,我华科(985)研二在读,本科211。对您的岗位很感兴趣,希望能获得一次投递机会。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务