Glob patterns are widely used to match addresses in Unix-based systems. They utilize specific meta characters to define portions of an address. In addition to the basic wildcards, you can also use character classes and negation to refine your matching.
?
: Matches any single character.*
: Matches any sequence of characters (including an empty sequence).[
...]
: Matches any one character enclosed in the brackets. You can specify ranges (e.g. [0-9]
) and include specific characters like a hyphen (e.g. [abc-]
). An unclosed bracket is considered invalid.[
...!]
: Matches any character that is not listed within the brackets.**
: Matches the current directory and all its subdirectories. This pattern must appear as a standalone path component (for example, **a
or b**
are invalid, and more than two consecutive asterisks are not permitted).<scheme>://<hostname>/<path>
for URLs, the pattern matches only the <hostname>/<path>
part, ignoring the <scheme>
.Glob Pattern | Matches | Does Not Match |
---|---|---|
*example.com |
|
|
example.com/** |
|
|
*.*.example.com |
|
|
api.*.example.com/v? |
|
|
docs.??.example.com/**/guide[0-9].pdf |
|
|
backup/[!0-9]*.zip |
|
|
*.txt |
|
|
file?.txt |
|
|
img[0-9].png |
|
|
doc[!0-9].pdf |
|
|
[*].log |
|
|
src/**/test/*.js |
|
|
report-*-202[0-2].pdf |
|
|
[
has a matching closing bracket ]
. An unclosed bracket will result in an error.**
wildcard as an independent path segment. Do not combine it with other characters (e.g., **a
or b**
are invalid).*
or **
is allowed in a sequence; using more than two consecutive asterisks is not permitted.?
wildcard strictly matches a single character. Make sure the number of characters in your pattern aligns with your expectations.[
...!]
), verify that the excluded characters are exactly those you intend to omit.