Glob
Glob is shell-style file-path pattern matching that uses wildcards such as * ** ? [] to match file names; it is simpler than regex.
Purpose
Provides simple pattern matching for file systems without the complex syntax of regex.
Mechanism
* matches any characters within a single path segment (excluding /); ** recursively matches multiple directory levels; ? matches a single character; [] matches a character class; {} matches optional groups. Expanded into file lists by the shell or libraries such as minimatch/picomatch. Widely used by .gitignore, npm, and Vite.
Use cases
- .gitignore and npm ignore rules
- Build-tool file include/exclude patterns
- Shell commands (ls *.js)
- IDE file filtering
Examples
- Input
src/**/*.tsOutputAll .ts files under src (recursive)** recursion
Common errors
- Confusing * with ** (single level vs recursive)
- ** must be enabled via configuration (e.g., in minimatch)
Related terms
Regular Expression
A regular expression is a formal language for describing string patterns, defining matching rules with metacharacters and quantifiers; it is widely used for search, validation, and extraction. GLOSSARY
Wildcard
Wildcards are simplified pattern-matching characters: * matches any sequence and ? matches a single character; commonly used for file-name and domain matching. GLOSSARY