micromatch /picomatch
Blazing fast and accurate glob matcher written JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions. Used by GraphQL, Jest, Astro, Snowpack, Storybook, bulma, Serverless, fdir, Netlify, AWS Amplify, Revogrid, rollup, routify, open-wc, imba, ava, docusaurus, fast-glob, globby, chokidar, anymatch, cloudflare/miniflare, pts, and more than 5 million projects! Please follow picomatch's author: https://github.com/jonschlinkert
★ 1,342⑂ 209👁 13⑃ 178● 90▤ 10
+1
日增长
+10
周增长
1,342
stars
209
forks
13
watchers
178
prs
90
issues
10
releases
README
Picomatch
Blazing fast and accurate glob matcher written in JavaScript.
No dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.
Why picomatch?
Lightweight - No dependencies
Minimal - Tiny API surface. Main export is a function that takes a glob pattern and returns a matcher function.
Fast - Loads in about 2ms (that's several times faster than a single frame of a HD movie at 60fps)
Performant - Use the returned matcher function to speed up repeat matching (like when watching files)
Accurate matching - Using wildcards ( and ?), globstars () for nested directories, advanced globbing with extglobs, braces, and POSIX brackets, and support for escaping special characters with \ or quotes.
Well tested - Thousands of unit tests
See the library comparison to other libraries.
Table of Contents
Click to expand
- Install
- Usage
- API
picomatch
.test
.matchBase
.isMatch
.parse
.scan
.compileRe
.makeRe
.toRegex
- Options
Picomatch options
Scan Options
Options Examples
- Globbing features
Basic globbing
Advanced globbing
Braces
Matching special characters as literals
- Library Comparisons
- Benchmarks
- Philosophies
- About
Author
License
_(TOC generated by verb using markdown-toc)_
Install
Install with npm:
sh
npm install --save picomatch
Usage
The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.
js
const pm = require('picomatch');
const isMatch = pm('.js');
console.log(isMatch('abcd')); //= false
console.log(isMatch('a.js')); //= true
console.log(isMatch('a.md')); //= false
console.log(isMatch('a/b.js')); //= false
API
picomatch
Creates a matcher function from one or more glob patterns. The returned function takes a string to match as its first argument, and returns true if the string is a match. The returned matcher function also takes a boolean as the second argument that, when true, returns an object with additional information.
Params
globs {String|Array}: One or more glob patterns.
options {Object=}
returns {Function=}: Returns a matcher function.
Example
js
const picomatch = require('picomatch');
// picomatch(glob[, options]);
const isMatch = picomatch('.!(a)');
console.log(isMatch('a.a')); //= false
console.log(isMatch('a.b')); //= true
// For environments without node.js, picomatch/posix provides you a dependency-free matcher, without automatic OS detection.
const picomatch = require('picomatch/posix');
// the same API, defaulting to posix paths
const isMatch = picomatch('a/');
console.log(isMatch('a\\b')); //= false
console.log(isMatch('a/b')); //= true
// you can still configure the matcher function to accept windows paths
const isMatch = picomatch('a/', { options: windows });
console.log(isMatch('a\\b')); //= true
console.log(isMatch('a/b')); //= true
.teTop issues
#247CVE-2026-112366 (ReDoS) reported in picomatch 4.0.7 - requesting fix/release guidance25 comments · 2026-11-03#234Vulnerability open - CVE-2026-11236611 comments · 2026-10-20#71Incorrectly matches `[1-5]` against `[1-5]`9 comments · 2020-09-26#107Behavior of parenthesis in match6 comments · 2022-05-03#59Regression since 2.1.16 comments · 2020-01-05#171Parentheses are not treated as literal characters5 comments · 2026-04-22#136different results picomatch vs minimatch5 comments · 2024-10-01#175Security Audit: picomatch v4.0.4 | Incomplete ReDoS Fix Bypass (P1)3 comments · 2026-06-09
Discussions
Latest release
4.0.7 4.0.7 2026-08-24What's Changed fix: handle terminal globstars in parenthesized patterns by @mrmlnc in https://github.com/micromatch/picomatch/pull/198 Full Changelog: https://github.com/micromatch/picomatch/compare/4.0.6...4.0.7