Strings In Depth2 / 19
Up next

Classify ASCII bytes

const std = @import("std");

pub fn main() void {
    const s = "ab12";
    var digits: usize = 0;
    for (s) |c| {
        if (std.ascii.isDigit(c)) digits += 1;
    }
    std.debug.print("{d} digits\n", .{digits});
}
What you're solving

std.ascii predicates on each byte