A compiled glob pattern that can be reused for repeated matching.
@eryx/glob Module
JSON
Path globbing for strings, arrays, and filesystem traversal.
Supported pattern features:
*: zero or more characters (within one path segment)?: exactly one character (within one path segment)[abc],[a-z],[!abc]: character classes**: zero or more path segments (globstar, segment-only)\\escapes metacharacters for literal matching
The engine is pure Luau and shared by both array matching and filesystem traversal helpers.
Summary
Classes
Functions
API Reference
Classes
Compiled
Properties
The original pattern string used for compilation.
Functions
glob.escape
Escape glob metacharacters in literal so the result matches literally.
Parameters
raw text to treat as a literal path fragment
Returns
escaped glob pattern
glob.hasMagic
Return whether pattern contains unescaped glob metacharacters.
Parameters
pattern text to inspect
Returns
true when *, ?, or [ appears unescaped
glob.compile
Compile a glob pattern into a reusable matcher object.
Parameters
glob pattern to compile
matching behavior options
Returns
frozen compiled matcher with pattern and match
glob.match
Test whether path matches pattern.
Parameters
candidate path
glob pattern
matching behavior options
Returns
true when the path matches
glob.filter
Filter an array of paths, returning only entries that match pattern.
Parameters
candidate paths
glob pattern
matching behavior options
Returns
matching paths in original order
glob.gmatch
Create an iterator over entries in paths that match pattern.
Parameters
candidate paths
glob pattern
matching behavior options
Returns
iterator yielding matching paths, then nil
glob.glob
Expand a filesystem glob relative to options.root.
Returned paths are relative to the root and normalized to / separators.
Parameters
glob pattern to evaluate
traversal and matching options
Returns
matched paths
glob.iglob
Create an iterator over filesystem glob results.
Parameters
glob pattern to evaluate
traversal and matching options
Returns
iterator yielding matched paths, then nil
Types
MatchOptions
Options used by string/array-based glob matching.
Whether wildcard segments may match names beginning with ..
Defaults to false.
Whether comparisons are case-sensitive.
Defaults to true.
GlobOptions
Options used by filesystem glob expansion. Extends MatchOptions with traversal controls.
Root directory used for filesystem traversal.
Defaults to ".".
Ignore pattern(s) evaluated against relative paths. Can be a single pattern or an array of patterns.
Whether directory symlinks should be traversed recursively.
Defaults to false.
If true, only files are returned.
If true, only directories are returned.