json_mlake ยท API

json.regex

Structs

Regex

struct Regex

A 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.

Functions

regex_full_match

def regex_full_match(pattern: String, text: String) -> Bool

Compile pattern and test it against the whole of text.

Args
pattern: An I-Regexp pattern.
text: The subject string.

Raises If the pattern is not a valid I-Regexp.