Open and answer this issue on GitHub.
ready · opened 2026-10-18 · updated 2026-10-28 · 0 comments
There was no regex in std. Text work used starts_with, split or counting loops; a grammar cannot stand in, because it is a PEG (ordered choice, possessive repetition: a*a never matches as a rule, and does as a regular expression).
scripts/site-issues.py to Nikaia: fence and heading detection became a longer counting loop.re.* uses): the owner chose the RE2 dialect, a wrapper around Rust crates where possible, and comptime RE = regex::compile("...").regex-automata 0.4.18’s source: dense and sparse DFAs serialize and are used from a borrowed &[u32] without a copy (from_bytes validates, from_bytes_unchecked reads only the header: label, byte order, version, alignment); the Thompson NFA, Pike VM, one-pass DFA, lazy DFA and meta::Regex do not serialize; the one-pass DFA searches anchored only; meta::Regex builds a full DFA only up to 30 NFA states / 40 KiB.grammar; the pattern decides what is built ((?:…) exists); the representation belongs in the type (Regex[E], regex::Any for a mix); code per pattern written in std on a general mechanism rather than a compiler special case (#906, ADR-specialization-1); an external review added: the engine never changes the match (locate unanchored, extract groups anchored), tables written for the target’s byte order. The record went through ADR-382 and ADR-384 as numbers taken elsewhere meanwhile, which led to naming records by topic (ADR-decision-records-1, #904).regex::Dynamic, add the rest step by step; leave positions out until ADR-374 (text::Pos) is built.match error names a type by its name or path; naming every type is complete), and a keeps defect for generic std types was fixed. Found and filed: #917, #918, #919; the short form catch { Type => … } decided as ADR-catch-1 (#912).ADR-regex-1 (why, rejected alternatives), ADR-specialization-1 (the mechanism S1/S2 are written on); specification Part I 2.6. In short:
"\\d".regex::Regex[E], E an engine type (Literal, OnePass, Dfa, TaggedDfa, BitNfa, FlatNfa, Dynamic); regex::Any for a mix; regex::compile(comptime p) chooses the engine while building (a written type is a contract), regex::dynamic(p) compiles at run time.NK1244), engine and tables laid down; std’s calls take comptime? self and are emitted per known pattern.Literal, S1 OnePass, S2 Dfa (code under the unroll limit, table above it), S3 TaggedDfa, S4 BitNfa, S5 FlatNfa; the floor is Dynamic. A match is located unanchored (S0, S2 forward and reverse, S5) and its groups extracted anchored over the span (S1, S3, S5).ref Array[u32] in the target’s byte order, read in place; the crate’s DFA via from_bytes_unchecked in a crate under crates/unsafe.regex-automata’s meta::Regex. D9: --comptime reports. D10: the crates parse, translate and determinise; the code that runs for a known pattern is ours.regex::Regex[regex::Dynamic], regex::Engine, regex::dynamic, is_match, find, find_all, captures (group, named), replace_all, split; a match is a text::Match with m.text() only. Not yet: regex::Any; positions (m.start, m.end, from:).m.start, m.end as text::Pos, from: on find and captures, groups’ positions. Tests: a multibyte text, a search from the end of a previous match.regex::compile on the floor: needs ADR-333 D3 (a comptime parameter) and ADR-specialization-1 D7 (a result type computed from it). At first it gives Regex[regex::Dynamic] and checks the pattern while building (NK1244, the engine’s message). regex::compile with a run-time value refused, the help naming regex::dynamic.regex::Dfa, forward and reverse dense DFA laid down for the target, a constant entry for the type, a crate under crates/unsafe opening them with from_bytes_unchecked; the report (D9) in --comptime.regex::dynamic (D5.1), a fuzz driver in Nikaia (a finding if std lacks what it needs); benches/regex/ with instruction counts against a tuned Rust program on the crate, same output first; it sets the default limits.regex::Any, when there is a second engine.demoted in the site-issues prototype with it. The commit that builds the last step says Fixes #673.