def octet.lead

bend-kit-netip@0.1.0.0 · netip.bend:55

import bend-kit-netip@0.1.0.0/netip.bend as Netip
import Base

55# 1 to 3 characters, and no leading zero unless the octet is "0".
56def octet.lead(s: String) -> Bool:
57  match s:
58    case SNil{}:
59      False{}
60    case SCon{Chr{c}, +t}:
61      Bool.and(Nat.is_le(String.length(t), 2n), Bool.or(Bool.not(U32.is_eq(c, 48)), String.is_empty(t)))

Uses (10)

Used by (1)