Every public name.

Generated from the packages' interfaces and their documentation. Types first, then functions and values, each in alphabetical order.

The library

Patterns, matches and the functions that drive them — the surface a caller meets.

moonregex

Types

Group

Which group a value names: Whole for the whole match, Num for a numbered parenthesis, Name for a named one.

This is the shape the methods work in. Callers do not have to build it — GroupKey is implemented by Int, by String and by this type, so m.group(1), m.group("year") and m.group(Whole) are one call.

  • to_group(Self) -> Self

Match

One match: where it sits in the text, and every group's span.

A span is a code-point range, so start and end read the way Python's do — characters, not UTF-16 units — and group slices the original text back out by those offsets.

  • after(Self) -> StringView

    The text after the match — core's MatchResult::after.

  • before(Self) -> StringView

    The text before the match — core's MatchResult::before.

  • capturesdict(Self) -> Map[String, Array[(Int32, Int32)]]

    Named groups to their captured spans — Python's Match.capturesdict.

  • content(Self) -> StringView

    The matched text — core's MatchResult::content, and Python's group(0).

  • endpos(Self) -> Int32

    The endpos the search was bounded by — Python's Match.endpos.

  • expand(Self, String) -> String raise @parse.Refused

    Expand the Python replacement language in template against this match — Python's Match.expand.

  • fuzzy_changes(Self) -> (Array[(Int32, Int32)], Array[(Int32, Int32)], Array[(Int32, Int32)])

    The individual edits of a fuzzy match, as (substitutions, insertions, deletions) each a list of (string_offset, pattern_offset); three empty lists when the pattern was not fuzzy — Python's Match.fuzzy_changes.

  • fuzzy_counts(Self) -> (Int32, Int32, Int32)

    The edit counts of a fuzzy match, as (substitutions, insertions, deletions); all zero when the pattern was not fuzzy — Python's Match.fuzzy_counts.

  • groupdict(Self, default? : String?) -> Map[String, String]

    Named groups to their captured strings, default filling those that took no part — Python's Match.groupdict.

  • groups(Self, default? : String?) -> Array[String?]

    All capturing groups (1..n) as strings, None for those that did not take part — Python's Match.groups.

  • lastgroup(Self) -> String?

    The name of the group lastindex points at, or None — Python's Match.lastgroup.

  • lastindex(Self) -> Int32?

    The number of the highest group that took part, or None — Python's Match.lastindex.

  • marks(Self) -> Array[String]

    The names of the marks (*MARK:name) set during the match, in the order they were set — an empty list when none were.

  • partial(Self) -> Bool

    Whether this match is a partial match — regex.Match.partial. True when the pattern was compiled with partial=true.

  • pattern(Self) -> Pattern

    The Pattern that produced this match.

  • pos(Self) -> Int32

    The pos the search started at — Python's Match.pos.

  • re(Self) -> Pattern

    The Pattern that produced this match — Python's Match.re.

  • string(Self) -> String

    The subject text.

Pattern

A compiled pattern: the tree it came from, the flat program it became, and the source, so it can answer what Python's re answers of a Pattern — its string, its flags, how many groups, and what they are named.

  • add(Self, Self) -> Self
  • capture(Self, String) -> Self raise @parse.Refused

    This pattern wrapped in a named capture group, as Regex::capture in core.

    The group is numbered after the ones the pattern already has, and groupindex gains name.

  • dialect(Self) -> @parse.Dialect

    The dialect the pattern was read under.

  • dump(Self) -> String

    The syntax tree re-printed, as Python's Pattern.dump would.

  • findall(Self, String, group? : Group, overlapped? : Bool, pos? : Int32, endpos? : Int32, limit? : Int32) -> Array[Strin…

    All non-overlapping matches, as findall at the module level.

  • finditer(Self, String, pos? : Int32, endpos? : Int32, overlapped? : Bool, limit? : Int32) -> Array[Match] raise @parse.…

    All matches as Match objects, as finditer at the module level.

  • flags(Self) -> @parse.Flags

    The effective flags.

  • full(Self, String, pos? : Int32, endpos? : Int32, limit? : Int32) -> Match? raise @parse.Refused

    Match the whole region pos..endpos.

  • groupindex(Self) -> Map[String, Array[Int32]]

    Group name to slot, as Python's Pattern.groupindex.

  • groups(Self) -> Int32

    How many capturing groups the pattern has, group 0 not counted — Python's Pattern.groups.

  • lor(Self, Self) -> Self
  • lower(Self) -> @string.Regex?

    The pattern as a core @string.Regex, when the core engine can run it.

    The core engine speaks one grammar, so this answers only for the patterns that fit inside it: literals, classes, ., ^, $, \b, \B, groups, alternation, quantifiers up to 256. Anything else — backreferences, lookaround, conditionals, recursion, atomic groups, fuzzy matching, \X, Unicode word boundaries, Python's $ — answers None, and the pattern runs on this library's own engine instead.

    The result is an ordinary @string.Regex: it can be handed to core's execute, find, split, replace_by, or to the lexer.

  • partial(Self) -> Bool

    Whether the pattern was compiled for partial matching.

  • pattern(Self) -> String

    The pattern's source text.

  • prefix(Self, String, pos? : Int32, limit? : Int32) -> Match? raise @parse.Refused

    Match only at pos.

  • repeat(Self, min? : Int32, max? : Int32, greedy? : Bool) -> Self raise @parse.Refused

    This pattern repeated, as Regex::repeat in core: min to max times, greedily unless greedy is off.

  • scanner(Self, String) -> Scanner

    Bind a Pattern to a text so its methods can scan that text incrementally.

  • search(Self, String, pos? : Int32, endpos? : Int32, limit? : Int32) -> Match? raise @parse.Refused

    Scan text for the leftmost match.

  • split(Self, String, maxsplit? : Int32, pos? : Int32, endpos? : Int32, limit? : Int32) -> Array[String?] raise @parse.Re…

    Split text on the pattern, as split at the module level.

  • string(StringView) -> Self

    A pattern that matches text literally, as @string.Regex::string does.

    Nothing in text is read as syntax — the caller does not have to escape it first.

  • sub(Self, String, String, count? : Int32, pos? : Int32, endpos? : Int32, limit? : Int32) -> String raise @parse.Refused

    Replace matches with repl, as sub at the module level.

  • sub_with(Self, String, (Match) -> String raise @parse.Refused, count? : Int32, pos? : Int32, endpos? : Int32, limit? :…

    Replace matches with f(match), as sub_with at the module level.

  • subf(Self, String, String, count? : Int32, pos? : Int32, endpos? : Int32, limit? : Int32) -> String raise @parse.Refused

    Replace matches with repl, as regex.subf — repl is a format template whose fields name groups ({}, {0}, {name}, {0[0]}), with an optional :spec.

  • subfn(Self, String, String, count? : Int32, pos? : Int32, endpos? : Int32, limit? : Int32) -> (String, Int32) raise @pa…

    Replace matches with repl, returning the new text and the count, as regex.subfn.

  • subn(Self, String, String, count? : Int32, pos? : Int32, endpos? : Int32, limit? : Int32) -> (String, Int32) raise @par…

    Replace matches with repl, returning the new text and the count, as subn at the module level.

  • subn_with(Self, String, (Match) -> String raise @parse.Refused, count? : Int32, pos? : Int32, endpos? : Int32, limit? :…

    Replace matches with f(match), as subn_with at the module level.

Scanner

A Scanner walks a fixed text from left to right, each call picking up where the last left off — Python's regex.Scanner, and the loop re's finditer runs internally. Build one with Pattern::scanner.

  • findall(Self, group? : Group, overlapped? : Bool) -> Array[String?] raise @parse.Refused

    Every remaining match from the current position, as group strings, advancing to the end of the text — Python's Scanner.findall.

  • finditer(Self, overlapped? : Bool) -> Array[Match] raise @parse.Refused

    Every remaining match from the current position, as Match objects, advancing to the end of the text — Python's Scanner.finditer.

  • full(Self) -> Match? raise @parse.Refused

    A full match of the region from the current position, advancing past it; None otherwise — Python's Scanner.full.

  • prefix(Self) -> Match? raise @parse.Refused

    A match anchored at the current position, advancing past it; None if the pattern does not match there — Python's Scanner.match.

  • search(Self) -> Match? raise @parse.Refused

    The next match from the current position, advancing past it; None once the text is exhausted — Python's Scanner.search.

  • split(Self, maxsplit? : Int32) -> Array[String?] raise @parse.Refused

    Split the remaining text on the pattern, advancing to the end — Python's Scanner.split.

  • sub(Self, String, count? : Int32) -> String raise @parse.Refused

    Replace every remaining match with repl, returning the new text — Python's Scanner.sub.

  • subn(Self, String, count? : Int32) -> (String, Int32) raise @parse.Refused

    Replace every remaining match with repl, returning the new text and advancing to the end — Python's Scanner.subn / Scanner.sub.

Functions

  • compile(StringView, flags? : @parse.Flags, dialect? : @parse.Dialect, lists? : Map[String, Array[String]], partial? : Bool) -> Pattern rais…

    Compile pattern into a Pattern.

    flags and dialect set the grammar; lists feeds \L<name> named lists; partial turns on partial matching. A pattern the grammar refuses is refused here, with where reading stopped.

  • escape(StringView, dialect? : @parse.Dialect, special_only? : Bool, literal_spaces? : Bool) -> String

    Escape pattern so the result matches it literally, under dialect.

    The three grammars do not agree on what needs escaping, so the same string comes back spelled three ways:

    - Python — Python's re.escape: the characters that can mean something to the grammar are backslashed, everything else is left alone. With special_only off every non-alphanumeric is escaped; literal_spaces stops spaces from being escaped. - Ecma262 — RegExp.escape of ECMA-262: punctuation that is not a syntax character becomes \x.., syntax characters are backslashed, and a leading alphanumeric is spelled \x.. too so the result can never read as a quantifier's neighbour. - Lexmatch — the @string.Regex grammar: its metacharacters are backslashed and control characters are spelled in the escapes that grammar knows (\n, \t, \u{..}), never \x...

  • findall(StringView, String, flags? : @parse.Flags, dialect? : @parse.Dialect, group? : Group, overlapped? : Bool, pos? : Int32, endpos? : I…

    All non-overlapping matches, as Python's re.findall.

    With no group named and the pattern holding one or none, the matches (or the single group) are returned. With two or more groups and no group given, the call is ambiguous and refused — pass group to say which to collect, or use finditer to walk Match objects that carry them all.

  • finditer(StringView, String, flags? : @parse.Flags, dialect? : @parse.Dialect, overlapped? : Bool, pos? : Int32, endpos? : Int32, limit? :…

    All matches as Match objects, as Python's re.finditer.

  • full(StringView, String, flags? : @parse.Flags, dialect? : @parse.Dialect, pos? : Int32, endpos? : Int32, limit? : Int32, lists? : Map[Stri…

    Match the whole region pos..endpos (Python's re.fullmatch).

  • prefix(StringView, String, flags? : @parse.Flags, dialect? : @parse.Dialect, pos? : Int32, limit? : Int32, lists? : Map[String, Array[Strin…

    Match only at pos (Python's re.match): fail unless the pattern matches where the scan begins, not somewhere later in the text.

  • search(StringView, String, flags? : @parse.Flags, dialect? : @parse.Dialect, pos? : Int32, endpos? : Int32, limit? : Int32, lists? : Map[St…

    Scan text for the leftmost match, as Python's re.search.

  • split(StringView, String, flags? : @parse.Flags, dialect? : @parse.Dialect, maxsplit? : Int32, pos? : Int32, endpos? : Int32, limit? : Int3…

    Split text on the pattern, as Python's re.split.

  • struct Scanner {
  • sub(StringView, String, String, flags? : @parse.Flags, dialect? : @parse.Dialect, count? : Int32, pos? : Int32, endpos? : Int32, limit? : I…

    Replace matches with repl, as Python's re.sub.

  • sub_with(StringView, (Match) -> String raise @parse.Refused, String, flags? : @parse.Flags, dialect? : @parse.Dialect, count? : Int32, pos?…

    Replace matches with the result of f(match), as Python's re.sub with a callable replacement.

  • subf(StringView, String, String, flags? : @parse.Flags, dialect? : @parse.Dialect, count? : Int32, pos? : Int32, endpos? : Int32, limit? :…

    Replace matches with repl, as regex.subf — repl is a format template whose fields name groups ({}, {0}, {name}, {0[0]}).

  • subfn(StringView, String, String, flags? : @parse.Flags, dialect? : @parse.Dialect, count? : Int32, pos? : Int32, endpos? : Int32, limit? :…

    Replace matches with repl, returning the new text and the count, as regex.subfn.

  • subn(StringView, String, String, flags? : @parse.Flags, dialect? : @parse.Dialect, count? : Int32, pos? : Int32, endpos? : Int32, limit? :…

    Replace matches with repl, returning the new text and how many matches were replaced, as Python's re.subn.

  • subn_with(StringView, (Match) -> String raise @parse.Refused, String, flags? : @parse.Flags, dialect? : @parse.Dialect, count? : Int32, pos…

    Replace matches with f(match), returning the new text and the count, as Python's re.subn with a callable replacement.

Values

  • let a : @parse.Flags
  • let ascii : @parse.Flags

    ascii — Python's re.ASCII.

  • let b : @parse.Flags
  • let bestmatch : @parse.Flags

    bestmatch — regex.BESTMATCH.

  • let default_version : @parse.Version

    The version the engine reads a Python pattern under when none is asked for.

  • let dialect : @parse.Dialect

    The preset dialect: Python's re.

  • let dotall : @parse.Flags

    dotall — Python's re.DOTALL.

  • let e : @parse.Flags
  • let ecma262 : @parse.Dialect

    The ECMA-262 RegExp dialect — JSON Schema and OpenAPI "string" patterns.

  • let enhancematch : @parse.Flags

    enhancematch — regex.ENHANCEMATCH.

  • let f : @parse.Flags
  • let flags : @parse.Flags

    The preset flags, for callers who want to tweak one and keep the rest.

  • let fullcase : @parse.Flags

    fullcase — Python's re.FULLCASE.

  • let i : @parse.Flags
  • let ignorecase : @parse.Flags

    ignorecase — Python's re.IGNORECASE.

  • let lexmatch_dialect : @parse.Dialect

    The MoonBit lexmatch dialect — @string.Regex and the lexer.

  • let m : @parse.Flags
  • let multiline : @parse.Flags

    multiline — Python's re.MULTILINE.

  • let p : @parse.Flags
  • let posix : @parse.Flags

    posix — regex.POSIX.

  • let python : @parse.Dialect

    The Python re dialect — the default, and the one most callers want.

  • let r : @parse.Flags
  • let reverse : @parse.Flags

    reverse — regex.REVERSE.

  • let s : @parse.Flags
  • let u : @parse.Flags
  • let unicode : @parse.Flags

    unicode — Python's re.UNICODE.

  • let v0 : @parse.Flags
  • let v1 : @parse.Flags
  • let verbose : @parse.Flags

    verbose — Python's re.VERBOSE.

  • let version : String

    The library version, as regex.__version__ reports it.

  • let version0 : @parse.Flags

    version0 — regex.VERSION0.

  • let version0_value : @parse.Version

    The V0 behaviour set, as a Version value — regex.VERSION0's target.

  • let version1 : @parse.Flags

    version1 — regex.VERSION1.

  • let version1_value : @parse.Version

    The V1 behaviour set, as a Version value — regex.VERSION1's target.

  • let version_info : (Int32, Int32, Int32)

    The library version split into (major, minor, patch), as regex.__version_info__ reports it.

  • let w : @parse.Flags
  • let word : @parse.Flags

    word — regex.WORD.

  • let x : @parse.Flags

parse

One syntax tree for three grammars: Python, ECMA-262 and lexmatch.

moonregex/parse

Types

Ast

A parsed pattern: the tree, and what the parse learned about it.

flags is the compile-time flags with the pattern's own global inline flags merged in — what Pattern::flags answers.

  • built(Node, groups~ : Int32, groupindex~ : Map[String, Array[Int32]], flags~ : Flags) -> Self

    An Ast assembled from parts rather than parsed, so patterns can be composed in code and still be the same kind of value as a parsed one.

  • dump(Self) -> String

    The syntax tree as text: what Pattern::dump answers.

    Not the pattern — a parse and re-print loses spacing and comments, and folds flags into the nodes — but close enough to read a pattern back from, which is what tests and debugging want.

  • flags(Self) -> Flags

    The effective flags.

  • groupindex(Self) -> Map[String, Array[Int32]]

    Group name to the slots carrying it.

  • groups(Self) -> Int32

    How many capture groups the pattern has.

  • named_lists(Self) -> Map[String, Array[String]]

    The named lists the pattern declared with \L<name>.

  • root(Self) -> Node

    The tree on its own, for the executor.

  • to_lexmatch(Self) -> String?

    The tree as a lexmatch pattern — what the core library's engine reads.

    None when the tree uses something that grammar cannot say, which is the line between the two engines: everything above it can be handed to the core library, everything below has to run here.

Flags

The switches a pattern can carry.

A record rather than a bitmask, because every one of these is a thing a reader may want to look at, set, or refuse — (?a) inside a scoped group changes what \w means for that group alone, and a bitmask cannot be asked about politely.

Flags are resolved into the syntax tree at parse time: (?s:.) puts the dotall behaviour inside the node, so the executor never consults them.

  • new(ignorecase? : Bool, multiline? : Bool, dotall? : Bool, verbose? : Bool, ascii? : Bool, unicode? : Bool, unicode_set…

    Build flags, leaving unset switches at their preset.

    A flag that is only meaningful in one dialect is accepted everywhere and refused by the parser when the grammar cannot honour it — verbose under ECMA-262, for instance — so that the mistake is named where it happens.

Node

One node of the syntax tree every dialect is lowered into.

The tree is resolved: flags have been folded into the nodes that care ((?s:.) is an Any that eats newlines, (?i)k is a class holding both cases), so the executor never asks which grammar a node came from.

  • shift_slots(Self, Int32) -> Self

    The tree with every capture slot moved up by by.

    Composing two patterns renumbers the right-hand one's groups so the result is numbered as one written pattern would be — the left operand keeps 1..n, the right one continues at n+1.

Functions

  • captured(Ast, name~ : String) -> Ast raise Refused

    a.capture(name) — one more group, numbered after the ones already there.

  • concat(Ast, Ast) -> Ast

    One after the other: a + b.

  • ecma_parse(StringView) -> Ast raise Refused

    Parse pattern as an ECMA-262 RegExp — the grammar JSON Schema and OpenAPI mean by a "string" pattern, and what a browser hands new RegExp.

    The tree is the same one Python's re reads into; only the dialect differs, so the executor never asks which grammar a node came from.

  • ecma_parse_with(StringView, Flags) -> Ast raise Refused

    Parse an ECMA-262 RegExp with the flags already chosen by the caller.

  • either(Ast, Ast) -> Ast

    One or the other: a | b.

  • enum Anchor {
  • enum Cond {
  • enum Look {
  • enum Node {
  • enum Recurse {
  • enum RecurseCond {
  • enum VerbKind {
  • lexmatch_parse(StringView) -> Ast raise Refused

    Parse pattern as a MoonBit lexmatch literal — the grammar MoonBit's own @string.Regex speaks, the lexer uses, and lexmatch documents.

  • lexmatch_parse_with(StringView, Flags) -> Ast raise Refused

    Parse a lexmatch literal with the flags already chosen by the caller.

  • literal(StringView) -> Ast

    An Ast matching exactly text, character for character.

  • parse(StringView, flags? : Flags, dialect? : Dialect, lists? : Map[String, Array[String]]) -> Ast raise Refused

    Read a pattern into the syntax tree.

    flags are the compile-time flags; the pattern's own global inline flags are merged into them as they are met, and the merged result is what Ast::flags answers.

  • repeated(Ast, min~ : Int32, max? : Int32, greedy~ : Bool) -> Ast raise Refused

    a.repeat(…).

  • struct Ast {
  • struct FuzzySpec {

Values

  • let dialect : Dialect

    The dialect a pattern is read under when the caller does not say.

  • let flags : Flags

    Everything off, unicode on, version V0.

    This is the preset every default argument points at, so a pattern written with no flags at all behaves the way Python's re does by default.

exec

The compiled program and the backtracking engine that runs it.

moonregex/exec

Types

Program

A compiled pattern: the flat program, the sub-programs for groups and other constructs, and how many capture groups it has (group 0 not counted).

  • full(Self, String, pos? : Int32, endpos? : Int32, limit? : Int32) -> MatchResult? raise @parse.Refused

    Match the whole region pos..endpos (Python's full).

  • prefix(Self, String, pos? : Int32, limit? : Int32) -> MatchResult? raise @parse.Refused

    Match only at pos (Python's match).

  • search(Self, String, pos? : Int32, endpos? : Int32, limit? : Int32, must_advance? : Bool) -> MatchResult? raise @parse.…

    Search left to right from pos to endpos, returning the leftmost match.

Functions

  • compile(@parse.Ast) -> Program

    Compile a parsed pattern into the flat program.

  • struct MatchResult {
  • struct Program {

prop

Code-point sets, the Unicode property lookups behind `\\p{…}`, and case folding.

moonregex/prop

Types

CharSet

A set of code points, kept as sorted disjoint inclusive ranges.

Character classes, \p{...}, \w and the rest are all this one shape, so the set algebra a pattern needs — union for [a-z], difference for --, intersection for &&, complement for [^…] — lives here once.

  • any() -> Self

    Every code point, surrogates included.

  • complement(Self) -> Self

    Complement over every code point: what [^…] means.

  • contains(Self, Int32) -> Bool

    Whether a code point is in the set.

  • difference(Self, Self) -> Self

    Difference: the V1 set algebra's --.

  • empty() -> Self

    The empty set.

  • fold(Self) -> Self

    Close the set under simple case folding: add the folded form of everything in it, and the unfolded form of everything that folds into it.

    This is what (?i) does to a class at parse time: fold the pattern, not the input, so the executor stays a plain membership test. Only single code point folds exist here, so ß does not grow an ss — matching it against SS is out of scope, exactly as it is in Python's re.

  • intersection(Self, Self) -> Self

    Intersection: the V1 set algebra's &&.

  • is_empty(Self) -> Bool

    Whether the set holds nothing.

  • of(Array[(Int32, Int32)]) -> Self

    Build a set from ranges, sorting and merging them first.

    The input may be in any order and may overlap; the stored form is always sorted, disjoint and coalesced, which is what makes contains a binary search and the algebra linear.

  • ranges(Self) -> Array[(Int32, Int32)]

    The stored ranges, sorted and disjoint.

  • single(Int32) -> Self

    A set holding exactly one code point.

  • symmetric_difference(Self, Self) -> Self

    Symmetric difference: the V1 set algebra's ~~.

  • union(Self, Self) -> Self

    Union: [a-z] or, in the V1 set algebra, ||.

Functions

  • binary(StringView) -> CharSet?

    A binary property: Alphabetic, White_Space, Emoji.

  • block(StringView) -> CharSet?

    A block: Basic Latin, BasicLatin, CJK Unified Ideographs.

    A block is one range, so the usual answer needs no walk at all; the walk is only for spellings the UCD's reader does not take.

  • category(StringView) -> CharSet?

    A general category: L, Lu, Uppercase_Letter, casedletter.

  • char_of_name(StringView) -> Int32?

    The code point a Unicode character name denotes — what \N{name} answers from. Names are read loosely, the way unicodedata.lookup reads them.

  • digit() -> CharSet

    \d: decimal digits, and only those.

  • fold(Char) -> Char

    The simple fold of a code point; a code point with no fold is its own.

  • fold_pairs() -> Array[(Int32, Int32)]

    The fold pairs, sorted by source — what a class is closed under.

  • property(StringView) -> CharSet?

    Any property, however it is spelled — the shape \p{...} takes.

    name=value is accepted too: Script=Latin, General_Category=Lu, Block=CJK Unified Ideographs. The left side picks the table, the right side the entry; without it, every table is searched in the order a Unicode name would be looked up: category, script, block, binary property.

  • script(StringView) -> CharSet?

    A script: Latin, Latn, Han.

    The short code and the long name are one name to the UCD, so the name is resolved through the UCD's own reader first and only then looked up.

  • space() -> CharSet

    \s: the White_Space property.

  • struct CharSet {
  • version() -> String

    Which Unicode the answers follow.

  • word() -> CharSet

    \w under the Python and mrab spellings: letters, numbers and the underscore. Python's own words for it are "alphanumeric (as str.isalnum has it) plus _", which is exactly these categories.

Values

  • let ascii_digit : CharSet
  • let ascii_space : CharSet
  • let ascii_word : CharSet

    The same three, restricted to ASCII, which is what the A flag and the ECMA-262 dialect without u mean by them.

glob

Shell globbing — `fnmatch`, `Glob` and `GlobSet`.

moonregex/glob

Types

Glob

A compiled glob: a pattern plus the regex it became.

  • compile(StringView, ignorecase? : Bool) -> Self raise @parse.Refused

    Compile a path glob.

    * matches a run of characters that are not separators; ** matches a run that may include them (zero or more path segments); ? matches one non-separator character; [...] is a character class; {a,b} is an alternation; and \ escapes the next character. Both / and \ are treated as separators, so Windows and POSIX paths match the same pattern.

  • matches(Self, String) -> Bool raise @parse.Refused

    Whether path matches the glob, as a whole anchored match.

  • pattern(Self) -> String

    The pattern this glob was compiled from.

GlobSet

A set of globs matched together — the workhorse behind an ignore file or a list of include patterns.

  • compile(Array[String], ignorecase? : Bool) -> Self raise @parse.Refused

    Compile several patterns into one set.

  • matches(Self, String) -> Array[Int32] raise @parse.Refused

    The indices of every pattern in the set that matches path.

  • matches_any(Self, String) -> Bool raise @parse.Refused

    Whether any pattern in the set matches path.

  • patterns(Self) -> Array[String]

    The patterns the set was compiled from, in order.

Functions

  • filter(Array[String], StringView, ignorecase? : Bool) -> Array[String] raise @parse.Refused

    The names that match pat, in the order given (Python's fnmatch.filter).

  • filter_paths(Array[String], StringView, ignorecase? : Bool) -> Array[String] raise @parse.Refused

    The paths that match the glob pattern, in the order given.

  • fnmatch(String, StringView, ignorecase? : Bool) -> Bool raise @parse.Refused

    Whether name matches the shell pattern pat.

    By default the match is case-sensitive (POSIX fnmatch). Pass ignorecase=true to fold case first, the way fnmatch does on a case-insensitive filesystem.

  • fnmatchcase(String, StringView) -> Bool raise @parse.Refused

    fnmatch without any case folding — an exact, case-sensitive match.

  • match_path(String, StringView, ignorecase? : Bool) -> Bool raise @parse.Refused

    Match one path against one glob pattern (compiling the pattern inline).

  • struct Glob {
  • struct GlobSet {
  • translate(StringView) -> String

    Turn a shell/fnmatch pattern into a regex fragment (no anchors).

    * and ? become .* and .; [...] becomes a character class (with ! or ^ for negation); {a,b,c} becomes an alternation; and \ escapes the next character. This is the fnmatch reading, where * may cross a path separator.