Zig regex tester
Test and debug regular expressions with Zeetah, a fast, dependency-free regex library for Zig. The real engine runs in your browser as WebAssembly, so what matches here matches in your Zig program.
Regular expression
Test string
$& whole match · $1 group · ${name} named · $$ dollar · g flag replaces every match
About Zeetah, the regex library behind this tester
Zeetah is an open-source (MIT) regular expression engine for Zig. It is a meta engine: when a pattern is compiled, Zeetah analyzes it and routes it to the cheapest matcher that is still correct. The status line above the test string shows which one your pattern got.
- Linear-time core. Regular patterns compile to a DFA and match in O(n); even
(a+)+$stays linear. - Bounded backtracking. Backreferences and lookaround run under a step budget and return
error.MatchBudgetExceededinstead of hanging. - SIMD where it pays. Teddy multi-literal search and 64-byte bitmask scans for character-class runs.
- Compile-time regex.
zeetah.Patternbuilds the matcher at comptime: no allocator, no runtime compile. - No dependencies. Zig standard library only; every allocation goes through the allocator you pass.
Frequently asked questions
What is Zeetah?
Zeetah is a fast, open-source (MIT) regular expression library for the Zig programming language, with no dependencies beyond the Zig standard library. It is a meta engine: when you compile a pattern it picks the cheapest correct matcher for it, such as a SIMD literal scan, a DFA, or a bounded backtracker for lookaround and backreferences.
How do I use regular expressions in Zig?
Zig's standard library has no regex module, so you add a library such as Zeetah. Run zig fetch --save with the Zeetah Git URL, import the zeetah module in build.zig, then call zeetah.Regex.compile(allocator, pattern) and use find, findAll, captures or replaceAll. The guide walks through each step.
Which regex syntax does Zeetah support?
Perl and PCRE style syntax: character classes and POSIX classes, \d \w \s and \b, anchors, greedy, lazy and possessive quantifiers, alternation, capturing, non-capturing and named groups, lookahead, fixed-width lookbehind, backreferences, atomic groups and the inline flags (?i) (?m) (?s) (?x). Matching is byte-oriented: \w and \d are ASCII and . matches one byte.
Is Zeetah safe from ReDoS (catastrophic backtracking)?
Regular patterns compile to a DFA and run in linear time, so classic catastrophic shapes like (a+)+$ stay fast. Only features that need backtracking (backreferences, lookaround, atomic groups) use a backtracker, and it runs under a step budget that returns error.MatchBudgetExceeded instead of hanging.
Can Zig compile a regex at compile time?
Yes. zeetah.Pattern("...", .{}) runs the whole regex compiler at comptime and bakes the matcher into the binary's read-only data. Matching then needs no allocator and no runtime compilation, and an invalid pattern is a compile error.
How fast is Zeetah?
In the 13-engine benchmark published in the Zeetah README (1 MiB corpus, count model), Zeetah's geometric-mean throughput was 1.51x Rust's regex crate, 3.32x RE2 and 0.82x PCRE2-JIT, and pure-literal search reached 31.5 GB/s. The Benchmark button in this tester measures your own pattern in the browser.
Does this tester behave like JavaScript's RegExp?
No. It runs the real Zeetah engine compiled to WebAssembly, so results match what your Zig program will see. Like JavaScript it uses leftmost-first matching, but Zeetah works on UTF-8 bytes: \w is ASCII, . matches a single byte, and match positions are byte offsets.
Is my text sent to a server?
No. The pattern and test string never leave your browser; compiling and matching happen locally in WebAssembly. Share links keep the state in the URL fragment, which browsers do not send to servers.