SCUA

News

A regex engine that cannot blow up

July 16, 2026

0.13.0 added a regex module, and we wrote the engine ourselves. That is normally a bad idea, so here is the reasoning.

Most regex engines backtrack. Feed one a pathological pattern, or perfectly innocent-looking input to the wrong pattern, and matching goes exponential: the "ReDoS" class of denial-of-service, where a one-line pattern pins a CPU for hours. SCUA's whole posture is that untrusted scripts get to run without you auditing every line, and a language that hands untrusted code an exponential CPU primitive has failed that posture in one import.

So the engine is linear-time by construction. No backtracking exists in it, every pattern runs in time proportional to the input, and the worst case is boring. It is also codepoint-native, matching the language's UTF-8 string model instead of bolting byte semantics onto text.

It is wired in where you already work: str.matches, str.find_re, and str.replace_re run a compiled pattern over strings, and fs.grep accepts one as its pattern, with context lines and compact output shapes on top.