A glob library for MoonBit, supporting wildcard pattern matching on file paths.
https://github.com/justjavac/moonbit-glob.git
A glob pattern matching library for MoonBit, supporting wildcard pattern matching on file paths and strings.
* (matches any characters) and ? (matches** (matches across directory* respects directory boundaries, **[abc]moon update
moon add justjavac/glob
// Match text files
let result = glob("*.txt", "readme.txt")
assert_eq(result, true)
// Single character wildcard
let result = glob("file?.log", "file1.log")
assert_eq(result, true)
// Cross-directory matching
let result = glob("**/*.mbt", "src/main.mbt")
assert_eq(result, true)
| Pattern | Description | Example | Matches | Doesn't Match |
|---|---|---|---|---|
* | Matches any characters (except path separators) | *.txt | file.txt, readme.txt | dir/file.txt |
** | Matches any characters (including path separators) | **/*.txt | dir/file.txt, a/b/c.txt | file.py |
? | Matches exactly one character | file?.txt | file1.txt, fileA.txt | file.txt, file12.txt |
[abc] | Character class (validation only) | file[123].txt | validated syntax only | not implemented |
| Literal | Matches exact characters | readme.txt | readme.txt | README.txt |
This project is licensed under the MIT License.