Expand description
NFA-based regex engine — zero-dependency, deterministic, linear-time.
Compiles regex patterns into NFA states, then executes via Thompson NFA simulation. No backtracking, no per-match heap allocation beyond the initial state-set swap buffers. Guarantees O(n×m) worst-case matching.
§Public API
| Function | Purpose |
|---|---|
is_match | Test whether the pattern matches anywhere |
find | Return the first match span (start, end) |
find_all | Return all non-overlapping match spans |
split | Split input by pattern, returning segment spans |
§Supported syntax (Perl-spirit subset)
. any byte (or any byte except \n without `s` flag)
\d ASCII digit [0-9]
\w ASCII word [a-zA-Z0-9_]
\s ASCII whitespace [\t\n\r\x0C\x20]
\D \W \S negated classes
[abc] character class
[^abc] negated character class
[a-z] character range
a|b alternation
(...) grouping
* zero or more (greedy)
+ one or more (greedy)
? zero or one (greedy)
*? +? ?? non-greedy (lazy) variants
^ start of input (or line in `m` mode)
$ end of input (or line in `m` mode)
\b word boundary
\\ literal backslash
\xNN hex byte§Flags
| Flag | Meaning |
|---|---|
i | Case-insensitive (ASCII only) |
m | Multiline (^/$ match line boundaries) |
s | Dotall (. matches \n) |
x | Extended (whitespace ignored, # comments) |