Skip to content

zcre

Compile-time regular expressions for Zig. Patterns passed to zcre.regex are parsed and compiled entirely at comptime; a RuntimeRegex is available for patterns only known at runtime.

const date = zcre.regex("(?<year>\\d{4})-(?<month>\\d{2})-(?<day>\\d{2})");
if (date.search("released 2026-11-28")) |m| {
const year = m.named("year").?;
}

Practical PCRE semantics

Pike VM with leftmost-first priority for regular patterns; bounded backtracking for back-references, atomic groups, possessive quantifiers, and nullable loops.

Verified against PCRE2

A differential suite of 9,104 generated comparisons — search and full modes, every capture span — runs on every push.

Benchmarked against CTRE

Paired, workload-identical benchmarks on Linux, macOS, and Windows CI runners, with live results published on this site.

Zero runtime setup

Static patterns are zero-sized types; all program data lives in type-level constants. No allocator, no construction, no teardown.