Debian Codegraph @

docs/content/en/quick-reference/glob-patterns.md

raw
1 ---
2 title: Glob patterns
3 description: A quick reference guide to glob pattern syntax and matching rules for wildcards, character sets, and delimiters, featuring illustrative examples.
4 categories: []
5 keywords: []
6 ---
7
8 {{% glossary-term "glob pattern" %}}
9
10 The table below details the supported glob pattern syntax and its matching behavior. Each example illustrates a specific match type, the pattern used, and the expected boolean result when evaluated against a test string.
11
12 | Match type | Glob pattern | Test string | Match? |
13 | :--- | :--- | :--- | :--- |
14 | Simple wildcard | `a/*.md` | `a/page.md` | true |
15 | Literal match | `'a/*.md'` | `a/*.md` | true |
16 | Single-level wildcard | `a/*/page.md` | `a/b/page.md` | true |
17 | Single-level wildcard | `a/*/page.md` | `a/b/c/page.md` | false |
18 | Multi-level wildcard | `a/**/page.md` | `a/b/c/page.md` | true |
19 | Single character | `file.???` | `file.txt` | true |
20 | Single character | `file.???` | `file.js` | false |
21 | Delimiter exclusion | `?at` | `f/at` | false |
22 | Character list | `f.[jt]xt` | `f.txt` | true |
23 | Negated list | `f.[!j]xt` | `f.txt` | true |
24 | Character range | `f.[a-c].txt` | `f.b.txt` | true |
25 | Character range | `f.[a-c].txt` | `f.z.txt` | false |
26 | Negated range | `f.[!a-c].txt` | `f.z.txt` | true |
27 | Pattern alternates | `*.{jpg,png}` | `logo.png` | true |
28 | No match | `*.{jpg,png}` | `logo.webp` | false |
29
30 The matching logic follows these rules:
31
32 - Standard wildcard (`*`) matches any character except for a delimiter.
33 - Super wildcard (`**`) matches any character including delimiters.
34 - Single character (`?`) matches exactly one character, excluding delimiters.
35 - Negation (`!`) matches any character except those specified in a list or range when used inside brackets.
36 - Character ranges (`[a-z]`) match any single character within the specified range.
37
38 The delimiter is a slash (`/`), except when matching semantic version strings, where the delimiter is a dot (`.`).