Regex
struct RegexA compiled I-Regexp pattern.
Compile once and match many times: nothing in full_match or
search mutates the program, and both allocate only the small
per-run state sets.
Implements Movable
- Fields
prog: List[_Inst]ranges: List[Int]
__init__
def __init__(out self, var prog: List[_Inst], var ranges: List[Int]) compile
def compile(pattern: String) -> Self Compile an I-Regexp pattern.
- Args
pattern: The pattern, in RFC 9485 syntax.
Raises If the pattern is not a valid I-Regexp, or if it would expand past the instruction cap.
full_match
def full_match(self, text: String) -> Bool Whether the whole of text matches.
This is I-Regexp's own semantics: a pattern is anchored to both
ends of the subject, which is what RFC 9535's match() needs.
search
def search(self, text: String) -> Bool Whether any substring of text matches.
This is what RFC 9535's search() needs. It is built here
rather than by wrapping the pattern in .*, because starting a
thread at every position costs one epsilon closure per
character instead of a second pass over the program.