题解 | #统计字符#

统计字符

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


全部评论

相关推荐

牛客83700679...:简历抄别人的,然后再投,有反馈就是简历不行,没反馈就是学历不行,多投多改只要技术不差机会总会有的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务