Whole-string capture-span extraction for patterns containing Regex.Group nodes - the "Phase B" this library's issue #18 tracks (Phase A, Regex.Group itself, only recognizes groups structurally; nothing extracted their matched spans until this).
Backed by Pike's VM: a Thompson-construction NFA compiled directly from a parsed Regex tree (unerased - unlike Subset.of, this needs every Regex.Group node, not none of them), executed as a priority-ordered set of "threads" (one per live NFA position) that all advance one input code point at a time, each carrying its own capture-register array - the technique RE2/Go's regexp/Rust's regex crate actually ship for general (non-"one-pass") captures. Guaranteed O(programSize × inputLength): at most one thread per program instruction survives each step (an equal-or-lower-priority duplicate reaching an already-live instruction is dropped), so there's no repeat of catastrophic-backtracking blowup - the same complexity discipline Subset.isEmpty's visited-state BFS already relies on.
This is a genuinely separate engine from Subset/TokenMatcher, not an extension of either - Subset.of erases every Group before deriving through a pattern specifically so its derivative algebra never has to reason about captures at all. Regex.scala's only changes for this feature are mechanical: Regex.Alt's parts became an order-preserving Vector instead of a Set (see its own doc comment for why - every no-backtracking submatch algorithm, Pike's VM included, needs leftmost-first alternation priority, which a Set can't record) with equals/hashCode overridden back to Set-like semantics so Subset's ACI-normalization/termination story is completely unaffected. Subset.scala/TokenMatcher.scala are untouched.
Whole-string match only (mirrors this library's only existing matching precedent, RegexConformanceTest's private matches helper) - no find/replace/split, and captures aren't wired into TokenMatcher's compiled DFA. Both are tracked separately (issue #53 for the former; a TokenMatcher follow-up for the latter).
Attributes
- Companion
- object
- Source
- Capture.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any