1 # micromatch [![NPM version](https://img.shields.io/npm/v/micromatch.svg?style=flat)](https://www.npmjs.com/package/micromatch) [![NPM monthly downloads](https://img.shields.io/npm/dm/micromatch.svg?style=flat)](https://npmjs.org/package/micromatch) [![NPM total downloads](https://img.shields.io/npm/dt/micromatch.svg?style=flat)](https://npmjs.org/package/micromatch) [![Linux Build Status](https://img.shields.io/travis/micromatch/micromatch.svg?style=flat&label=Travis)](https://travis-ci.org/micromatch/micromatch) [![Windows Build Status](https://img.shields.io/appveyor/ci/micromatch/micromatch.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/micromatch/micromatch)
3 > Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.
5 Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
10 <summary><strong>Details</strong></summary>
13 - [Quickstart](#quickstart)
14 - [Why use micromatch?](#why-use-micromatch)
15 * [Matching features](#matching-features)
16 - [Switching to micromatch](#switching-to-micromatch)
17 * [From minimatch](#from-minimatch)
18 * [From multimatch](#from-multimatch)
21 * [options.basename](#optionsbasename)
22 * [options.bash](#optionsbash)
23 * [options.cache](#optionscache)
24 * [options.dot](#optionsdot)
25 * [options.failglob](#optionsfailglob)
26 * [options.ignore](#optionsignore)
27 * [options.matchBase](#optionsmatchbase)
28 * [options.nobrace](#optionsnobrace)
29 * [options.nocase](#optionsnocase)
30 * [options.nodupes](#optionsnodupes)
31 * [options.noext](#optionsnoext)
32 * [options.nonegate](#optionsnonegate)
33 * [options.noglobstar](#optionsnoglobstar)
34 * [options.nonull](#optionsnonull)
35 * [options.nullglob](#optionsnullglob)
36 * [options.snapdragon](#optionssnapdragon)
37 * [options.sourcemap](#optionssourcemap)
38 * [options.unescape](#optionsunescape)
39 * [options.unixify](#optionsunixify)
40 - [Extended globbing](#extended-globbing)
41 * [extglobs](#extglobs)
43 * [regex character classes](#regex-character-classes)
44 * [regex groups](#regex-groups)
45 * [POSIX bracket expressions](#posix-bracket-expressions)
47 * [Bash 4.3 parity](#bash-43-parity)
48 * [Backslashes](#backslashes)
49 - [Contributing](#contributing)
50 - [Benchmarks](#benchmarks)
51 * [Running benchmarks](#running-benchmarks)
52 * [Latest results](#latest-results)
59 Install with [npm](https://www.npmjs.com/):
62 $ npm install --save micromatch
68 var mm = require('micromatch');
69 mm(list, patterns[, options]);
72 The [main export](#micromatch) takes a list of strings and one or more glob patterns:
75 console.log(mm(['foo', 'bar', 'qux'], ['f*', 'b*']));
79 Use [.isMatch()](#ismatch) to get true/false:
82 console.log(mm.isMatch('foo', 'f*'));
86 [Switching](#switching-to-micromatch) from minimatch and multimatch is easy!
88 ## Why use micromatch?
90 > micromatch is a [drop-in replacement](#switching-to-micromatch) for minimatch and multimatch
92 * Supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch)
93 * Micromatch uses [snapdragon](https://github.com/jonschlinkert/snapdragon) for parsing and compiling globs, which provides granular control over the entire conversion process in a way that is easy to understand, reason about, and maintain.
94 * More consistently accurate matching [than minimatch](https://github.com/yarnpkg/yarn/pull/3339), with more than 36,000 [test assertions](./test) to prove it.
95 * More complete support for the Bash 4.3 specification than minimatch and multimatch. In fact, micromatch passes _all of the spec tests_ from bash, including some that bash still fails.
96 * [Faster matching](#benchmarks), from a combination of optimized glob patterns, faster algorithms, and regex caching.
97 * [Micromatch is safer](https://github.com/micromatch/braces#braces-is-safe), and is not subject to DoS with brace patterns, like minimatch and multimatch.
98 * More reliable windows support than minimatch and multimatch.
100 ### Matching features
102 * Support for multiple glob patterns (no need for wrappers like multimatch)
103 * Wildcards (`**`, `*.js`)
104 * Negation (`'!a/*.js'`, `'*!(b).js']`)
105 * [extglobs](https://github.com/micromatch/extglob) (`+(x|y)`, `!(a|b)`)
106 * [POSIX character classes](https://github.com/micromatch/expand-brackets) (`[[:alpha:][:digit:]]`)
107 * [brace expansion](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`)
108 * regex character classes (`foo-[1-5].js`)
109 * regex logical "or" (`foo/(abc|xyz).js`)
111 You can mix and match these features to create whatever patterns you need!
113 ## Switching to micromatch
115 There is one notable difference between micromatch and minimatch in regards to how backslashes are handled. See [the notes about backslashes](#backslashes) for more information.
119 Use [mm.isMatch()](#ismatch) instead of `minimatch()`:
122 mm.isMatch('foo', 'b*');
126 Use [mm.match()](#match) instead of `minimatch.match()`:
129 mm.match(['foo', 'bar'], 'b*');
138 mm(['foo', 'bar', 'baz'], ['f*', '*z']);
144 ### [micromatch](index.js#L41)
146 The main function takes a list of strings and one or more glob patterns to use for matching.
150 * `list` **{Array}**: A list of strings to match
151 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
152 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
153 * `returns` **{Array}**: Returns an array of matches
158 var mm = require('micromatch');
159 mm(list, patterns[, options]);
161 console.log(mm(['a.js', 'a.txt'], ['*.js']));
165 ### [.match](index.js#L93)
167 Similar to the main function, but `pattern` must be a string.
171 * `list` **{Array}**: Array of strings to match
172 * `pattern` **{String}**: Glob pattern to use for matching.
173 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
174 * `returns` **{Array}**: Returns an array of matches
179 var mm = require('micromatch');
180 mm.match(list, pattern[, options]);
182 console.log(mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a'));
186 ### [.isMatch](index.js#L154)
188 Returns true if the specified `string` matches the given glob `pattern`.
192 * `string` **{String}**: String to match
193 * `pattern` **{String}**: Glob pattern to use for matching.
194 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
195 * `returns` **{Boolean}**: Returns true if the string matches the glob pattern.
200 var mm = require('micromatch');
201 mm.isMatch(string, pattern[, options]);
203 console.log(mm.isMatch('a.a', '*.a'));
205 console.log(mm.isMatch('a.b', '*.a'));
209 ### [.some](index.js#L192)
211 Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
215 * `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found.
216 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
217 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
218 * `returns` **{Boolean}**: Returns true if any patterns match `str`
223 var mm = require('micromatch');
224 mm.some(list, patterns[, options]);
226 console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
228 console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
232 ### [.every](index.js#L228)
234 Returns true if every string in the given `list` matches any of the given glob `patterns`.
238 * `list` **{String|Array}**: The string or array of strings to test.
239 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
240 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
241 * `returns` **{Boolean}**: Returns true if any patterns match `str`
246 var mm = require('micromatch');
247 mm.every(list, patterns[, options]);
249 console.log(mm.every('foo.js', ['foo.js']));
251 console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
253 console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
255 console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
259 ### [.any](index.js#L260)
261 Returns true if **any** of the given glob `patterns` match the specified `string`.
265 * `str` **{String|Array}**: The string to test.
266 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
267 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
268 * `returns` **{Boolean}**: Returns true if any patterns match `str`
273 var mm = require('micromatch');
274 mm.any(string, patterns[, options]);
276 console.log(mm.any('a.a', ['b.*', '*.a']));
278 console.log(mm.any('a.a', 'b.*'));
282 ### [.all](index.js#L308)
284 Returns true if **all** of the given `patterns` match the specified string.
288 * `str` **{String|Array}**: The string to test.
289 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
290 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
291 * `returns` **{Boolean}**: Returns true if any patterns match `str`
296 var mm = require('micromatch');
297 mm.all(string, patterns[, options]);
299 console.log(mm.all('foo.js', ['foo.js']));
302 console.log(mm.all('foo.js', ['*.js', '!foo.js']));
305 console.log(mm.all('foo.js', ['*.js', 'foo.js']));
308 console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
312 ### [.not](index.js#L340)
314 Returns a list of strings that _**do not match any**_ of the given `patterns`.
318 * `list` **{Array}**: Array of strings to match.
319 * `patterns` **{String|Array}**: One or more glob pattern to use for matching.
320 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
321 * `returns` **{Array}**: Returns an array of strings that **do not match** the given patterns.
326 var mm = require('micromatch');
327 mm.not(list, patterns[, options]);
329 console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
333 ### [.contains](index.js#L376)
335 Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.
339 * `str` **{String}**: The string to match.
340 * `patterns` **{String|Array}**: Glob pattern to use for matching.
341 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
342 * `returns` **{Boolean}**: Returns true if the patter matches any part of `str`.
347 var mm = require('micromatch');
348 mm.contains(string, pattern[, options]);
350 console.log(mm.contains('aa/bb/cc', '*b'));
352 console.log(mm.contains('aa/bb/cc', '*d'));
356 ### [.matchKeys](index.js#L432)
358 Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead.
362 * `object` **{Object}**: The object with keys to filter.
363 * `patterns` **{String|Array}**: One or more glob patterns to use for matching.
364 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
365 * `returns` **{Object}**: Returns an object with only keys that match the given patterns.
370 var mm = require('micromatch');
371 mm.matchKeys(object, patterns[, options]);
373 var obj = { aa: 'a', ab: 'b', ac: 'c' };
374 console.log(mm.matchKeys(obj, '*b'));
378 ### [.matcher](index.js#L461)
380 Returns a memoized matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match.
384 * `pattern` **{String}**: Glob pattern
385 * `options` **{Object}**: See available [options](#options) for changing how matches are performed.
386 * `returns` **{Function}**: Returns a matcher function.
391 var mm = require('micromatch');
392 mm.matcher(pattern[, options]);
394 var isMatch = mm.matcher('*.!(*a)');
395 console.log(isMatch('a.a'));
397 console.log(isMatch('a.b'));
401 ### [.capture](index.js#L536)
403 Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
407 * `pattern` **{String}**: Glob pattern to use for matching.
408 * `string` **{String}**: String to match
409 * `options` **{Object}**: See available [options](#options) for changing how matches are performed
410 * `returns` **{Boolean}**: Returns an array of captures if the string matches the glob pattern, otherwise `null`.
415 var mm = require('micromatch');
416 mm.capture(pattern, string[, options]);
418 console.log(mm.capture('test/*.js', 'test/foo.js'));
420 console.log(mm.capture('test/*.js', 'foo/bar.css'));
424 ### [.makeRe](index.js#L571)
426 Create a regular expression from the given glob `pattern`.
430 * `pattern` **{String}**: A glob pattern to convert to regex.
431 * `options` **{Object}**: See available [options](#options) for changing how matches are performed.
432 * `returns` **{RegExp}**: Returns a regex created from the given pattern.
437 var mm = require('micromatch');
438 mm.makeRe(pattern[, options]);
440 console.log(mm.makeRe('*.js'));
441 //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
444 ### [.braces](index.js#L618)
446 Expand the given brace `pattern`.
450 * `pattern` **{String}**: String with brace pattern to expand.
451 * `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options.
452 * `returns` **{Array}**
457 var mm = require('micromatch');
458 console.log(mm.braces('foo/{a,b}/bar'));
459 //=> ['foo/(a|b)/bar']
461 console.log(mm.braces('foo/{a,b}/bar', {expand: true}));
462 //=> ['foo/(a|b)/bar']
465 ### [.create](index.js#L685)
467 Parses the given glob `pattern` and returns an array of abstract syntax trees (ASTs), with the compiled `output` and optional source `map` on each AST.
471 * `pattern` **{String}**: Glob pattern to parse and compile.
472 * `options` **{Object}**: Any [options](#options) to change how parsing and compiling is performed.
473 * `returns` **{Object}**: Returns an object with the parsed AST, compiled string and optional source map.
478 var mm = require('micromatch');
479 mm.create(pattern[, options]);
481 console.log(mm.create('abc/*.js'));
482 // [{ options: { source: 'string', sourcemap: true },
486 // output: '(\\.[\\\\\\/])?abc\\/(?!\\.)(?=.)[^\\/]*?\\.js',
493 // input: 'abc/*.js' },
494 // parsingErrors: [],
497 // sources: [ 'string' ],
499 // mappings: 'AAAA,GAAG,EAAC,kBAAC,EAAC,EAAE',
500 // sourcesContent: [ 'abc/*.js' ] },
501 // position: { line: 1, column: 28 },
507 ### [.parse](index.js#L732)
509 Parse the given `str` with the given `options`.
514 * `options` **{Object}**
515 * `returns` **{Object}**: Returns an AST
520 var mm = require('micromatch');
521 mm.parse(pattern[, options]);
523 var ast = mm.parse('a/{b,c}/d');
527 // input: 'a/{b,c}/d',
529 // [ { type: 'bos', val: '' },
530 // { type: 'text', val: 'a/' },
533 // [ { type: 'brace.open', val: '{' },
534 // { type: 'text', val: 'b,c' },
535 // { type: 'brace.close', val: '}' } ] },
536 // { type: 'text', val: '/d' },
537 // { type: 'eos', val: '' } ] }
540 ### [.compile](index.js#L780)
542 Compile the given `ast` or string with the given `options`.
546 * `ast` **{Object|String}**
547 * `options` **{Object}**
548 * `returns` **{Object}**: Returns an object that has an `output` property with the compiled string.
553 var mm = require('micromatch');
554 mm.compile(ast[, options]);
556 var ast = mm.parse('a/{b,c}/d');
557 console.log(mm.compile(ast));
558 // { options: { source: 'string' },
561 // { eos: [Function],
564 // brace: [Function],
565 // 'brace.open': [Function],
567 // 'brace.close': [Function] },
568 // output: [ 'a/(b|c)/d' ],
571 // parsingErrors: [] }
574 ### [.clearCache](index.js#L801)
576 Clear the regex cache.
586 * [basename](#optionsbasename)
587 * [bash](#optionsbash)
588 * [cache](#optionscache)
590 * [failglob](#optionsfailglob)
591 * [ignore](#optionsignore)
592 * [matchBase](#optionsmatchBase)
593 * [nobrace](#optionsnobrace)
594 * [nocase](#optionsnocase)
595 * [nodupes](#optionsnodupes)
596 * [noext](#optionsnoext)
597 * [noglobstar](#optionsnoglobstar)
598 * [nonull](#optionsnonull)
599 * [nullglob](#optionsnullglob)
600 * [snapdragon](#optionssnapdragon)
601 * [sourcemap](#optionssourcemap)
602 * [unescape](#optionsunescape)
603 * [unixify](#optionsunixify)
607 Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`.
616 mm(['a/b.js', 'a/c.md'], '*.js');
619 mm(['a/b.js', 'a/c.md'], '*.js', {matchBase: true});
625 Enabled by default, this option enforces bash-like behavior with stars immediately following a bracket expression. Bash bracket expressions are similar to regex character classes, but unlike regex, a star following a bracket expression **does not repeat the bracketed characters**. Instead, the star is treated the same as an other star.
634 var files = ['abc', 'ajz'];
635 console.log(mm(files, '[a-c]*'));
638 console.log(mm(files, '[a-c]*', {bash: false}));
643 Disable regex and function memoization.
647 **Default**: `undefined`
651 Match dotfiles. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `dot`.
659 Similar to the `--failglob` behavior in Bash, throws an error when no matches are found.
663 **Default**: `undefined`
667 String or array of glob patterns to match files to ignore.
669 **Type**: `String|Array`
671 **Default**: `undefined`
673 ### options.matchBase
675 Alias for [options.basename](#options-basename).
679 Disable expansion of brace patterns. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nobrace`.
683 **Default**: `undefined`
685 See [braces](https://github.com/micromatch/braces) for more information about extended brace expansion.
689 Use a case-insensitive regex for matching files. Same behavior as [minimatch](https://github.com/isaacs/minimatch).
693 **Default**: `undefined`
697 Remove duplicate elements from the result array.
701 **Default**: `undefined`
705 Example of using the `unescape` and `nodupes` options together:
708 mm.match(['a/b/c', 'a/b/c'], 'a/b/c');
709 //=> ['a/b/c', 'a/b/c']
711 mm.match(['a/b/c', 'a/b/c'], 'a/b/c', {nodupes: true});
717 Disable extglob support, so that extglobs are regarded as literal characters.
721 **Default**: `undefined`
726 mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)');
727 //=> ['a/b', 'a/!(z)']
729 mm(['a/z', 'a/b', 'a/!(z)'], 'a/!(z)', {noext: true});
730 //=> ['a/!(z)'] (matches only as literal characters)
735 Disallow negation (`!`) patterns, and treat leading `!` as a literal character to match.
739 **Default**: `undefined`
741 ### options.noglobstar
743 Disable matching with globstars (`**`).
747 **Default**: `undefined`
750 mm(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**');
751 //=> ['a/b', 'a/b/c', 'a/b/c/d']
753 mm(['a/b', 'a/b/c', 'a/b/c/d'], 'a/**', {noglobstar: true});
759 Alias for [options.nullglob](#options-nullglob).
763 If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`.
767 **Default**: `undefined`
769 ### options.snapdragon
771 Pass your own instance of [snapdragon](https://github.com/jonschlinkert/snapdragon), to customize parsers or compilers.
775 **Default**: `undefined`
777 ### options.sourcemap
779 Generate a source map by enabling the `sourcemap` option with the `.parse`, `.compile`, or `.create` methods.
781 _(Note that sourcemaps are currently not enabled for brace patterns)_
786 var mm = require('micromatch');
787 var pattern = '*(*(of*(a)x)z)';
789 var res = mm.create('abc/*.js', {sourcemap: true});
790 console.log(res.map);
792 // sources: [ 'string' ],
794 // mappings: 'AAAA,GAAG,EAAC,iBAAC,EAAC,EAAE',
795 // sourcesContent: [ 'abc/*.js' ] }
797 var ast = mm.parse('abc/**/*.js');
798 var res = mm.compile(ast, {sourcemap: true});
799 console.log(res.map);
801 // sources: [ 'string' ],
803 // mappings: 'AAAA,GAAG,EAAC,2BAAE,EAAC,iBAAC,EAAC,EAAE',
804 // sourcesContent: [ 'abc/**/*.js' ] }
806 var ast = mm.parse(pattern);
807 var res = mm.compile(ast, {sourcemap: true});
808 console.log(res.map);
810 // sources: [ 'string' ],
812 // mappings: 'AAAA,CAAE,CAAE,EAAE,CAAE,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC',
813 // sourcesContent: [ '*(*(of*(a)x)z)' ] }
818 Remove backslashes from returned matches.
822 **Default**: `undefined`
826 In this example we want to match a literal `*`:
829 mm.match(['abc', 'a\\*c'], 'a\\*c');
832 mm.match(['abc', 'a\\*c'], 'a\\*c', {unescape: true});
838 Convert path separators on returned files to posix/unix-style forward slashes.
842 **Default**: `true` on windows, `false` everywhere else
847 mm.match(['a\\b\\c'], 'a/**');
850 mm.match(['a\\b\\c'], {unixify: false});
856 Micromatch also supports extended globbing features.
860 Extended globbing, as described by the bash man page:
862 | **pattern** | **regex equivalent** | **description** |
864 | `?(pattern)` | `(pattern)?` | Matches zero or one occurrence of the given patterns |
865 | `*(pattern)` | `(pattern)*` | Matches zero or more occurrences of the given patterns |
866 | `+(pattern)` | `(pattern)+` | Matches one or more occurrences of the given patterns |
867 | `@(pattern)` | `(pattern)` <sup>*</sup> | Matches one of the given patterns |
868 | `!(pattern)` | N/A (equivalent regex is much more complicated) | Matches anything except one of the given patterns |
870 <sup><strong>*</strong></sup> Note that `@` isn't a RegEx character.
872 Powered by [extglob](https://github.com/micromatch/extglob). Visit that library for the full range of options or to report extglob related issues.
876 Brace patterns can be used to match specific ranges or sets of characters. For example, the pattern `*/{1..3}/*` would match any of following strings:
887 Visit [braces](https://github.com/micromatch/braces) to see the full range of features and options related to brace expansion, or to create brace matching or expansion related issues.
889 ### regex character classes
891 Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`:
893 * `[ac].js`: matches both `a` and `c`, returning `['a.js', 'c.js']`
894 * `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']`
895 * `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']`
896 * `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']`
898 Learn about [regex character classes](http://www.regular-expressions.info/charclass.html).
902 Given `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`:
904 * `(a|c).js`: would match either `a` or `c`, returning `['a.js', 'c.js']`
905 * `(b|d).js`: would match either `b` or `d`, returning `['b.js', 'd.js']`
906 * `(b|[A-Z]).js`: would match either `b` or an uppercase letter, returning `['b.js', 'E.js']`
908 As with regex, parens can be nested, so patterns like `((a|b)|c)/b` will work. Although brace expansion might be friendlier to use, depending on preference.
910 ### POSIX bracket expressions
912 POSIX brackets are intended to be more user-friendly than regex character classes. This of course is in the eye of the beholder.
917 mm.isMatch('a1', '[[:alpha:][:digit:]]');
920 mm.isMatch('a1', '[[:alpha:][:alpha:]]');
924 See [expand-brackets](https://github.com/jonschlinkert/expand-brackets) for more information about bracket expressions.
932 Whenever possible matching behavior is based on behavior Bash 4.3, which is mostly consistent with minimatch.
934 However, it's suprising how many edge cases and rabbit holes there are with glob matching, and since there is no real glob specification, and micromatch is more accurate than both Bash and minimatch, there are cases where best-guesses were made for behavior. In a few cases where Bash had no answers, we used wildmatch (used by git) as a fallback.
938 There is an important, notable difference between minimatch and micromatch _in regards to how backslashes are handled_ in glob patterns.
940 * Micromatch exclusively and explicitly reserves backslashes for escaping characters in a glob pattern, even on windows. This is consistent with bash behavior.
941 * Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns.
943 We made this decision for micromatch for a couple of reasons:
945 * consistency with bash conventions.
946 * glob patterns are not filepaths. They are a type of [regular language](https://en.wikipedia.org/wiki/Regular_language) that is converted to a JavaScript regular expression. Thus, when forward slashes are defined in a glob pattern, the resulting regular expression will match windows or POSIX path separators just fine.
948 **A note about joining paths to globs**
950 Note that when you pass something like `path.join('foo', '*')` to micromatch, you are creating a filepath and expecting it to still work as a glob pattern. This causes problems on windows, since the `path.sep` is `\\`.
952 In other words, since `\\` is reserved as an escape character in globs, on windows `path.join('foo', '*')` would result in `foo\\*`, which tells micromatch to match `*` as a literal character. This is the same behavior as bash.
956 All contributions are welcome! Please read [the contributing guide](.github/contributing.md) to get started.
960 Please create an issue if you encounter a bug or matching behavior that doesn't seem correct. If you find a matching-related issue, please:
962 * [research existing issues first](../../issues) (open and closed)
963 * visit the [GNU Bash documentation](https://www.gnu.org/software/bash/manual/) to see how Bash deals with the pattern
964 * visit the [minimatch](https://github.com/isaacs/minimatch) documentation to cross-check expected behavior in node.js
965 * if all else fails, since there is no real specification for globs we will probably need to discuss expected behavior and decide how to resolve it. which means any detail you can provide to help with this discussion would be greatly appreciated.
969 It's important to us that micromatch work consistently on all platforms. If you encounter any platform-specific matching or path related issues, please let us know (pull requests are also greatly appreciated).
973 ### Running benchmarks
975 Install dev dependencies:
978 npm i -d && npm run benchmark
983 As of February 18, 2018 (longer bars are better):
986 # braces-globstar-large-list (485691 bytes)
987 micromatch ██████████████████████████████████████████████████ (517 ops/sec ±0.49%)
988 minimatch █ (18.92 ops/sec ±0.54%)
989 multimatch █ (18.94 ops/sec ±0.62%)
991 micromatch is faster by an avg. of 2,733%
993 # braces-multiple (3362 bytes)
994 micromatch ██████████████████████████████████████████████████ (33,625 ops/sec ±0.45%)
995 minimatch (2.92 ops/sec ±3.26%)
996 multimatch (2.90 ops/sec ±2.76%)
998 micromatch is faster by an avg. of 1,156,935%
1000 # braces-range (727 bytes)
1001 micromatch █████████████████████████████████████████████████ (155,220 ops/sec ±0.56%)
1002 minimatch ██████ (20,186 ops/sec ±1.27%)
1003 multimatch ██████ (19,809 ops/sec ±0.60%)
1005 micromatch is faster by an avg. of 776%
1007 # braces-set (2858 bytes)
1008 micromatch █████████████████████████████████████████████████ (24,354 ops/sec ±0.92%)
1009 minimatch █████ (2,566 ops/sec ±0.56%)
1010 multimatch ████ (2,431 ops/sec ±1.25%)
1012 micromatch is faster by an avg. of 975%
1014 # globstar-large-list (485686 bytes)
1015 micromatch █████████████████████████████████████████████████ (504 ops/sec ±0.45%)
1016 minimatch ███ (33.36 ops/sec ±1.08%)
1017 multimatch ███ (33.19 ops/sec ±1.35%)
1019 micromatch is faster by an avg. of 1,514%
1021 # globstar-long-list (90647 bytes)
1022 micromatch ██████████████████████████████████████████████████ (2,694 ops/sec ±1.08%)
1023 minimatch ████████████████ (870 ops/sec ±1.09%)
1024 multimatch ████████████████ (862 ops/sec ±0.84%)
1026 micromatch is faster by an avg. of 311%
1028 # globstar-short-list (182 bytes)
1029 micromatch ██████████████████████████████████████████████████ (328,921 ops/sec ±1.06%)
1030 minimatch █████████ (64,808 ops/sec ±1.42%)
1031 multimatch ████████ (57,991 ops/sec ±2.11%)
1033 micromatch is faster by an avg. of 536%
1035 # no-glob (701 bytes)
1036 micromatch █████████████████████████████████████████████████ (415,935 ops/sec ±0.36%)
1037 minimatch ███████████ (92,730 ops/sec ±1.44%)
1038 multimatch █████████ (81,958 ops/sec ±2.13%)
1040 micromatch is faster by an avg. of 476%
1042 # star-basename-long (12339 bytes)
1043 micromatch █████████████████████████████████████████████████ (7,963 ops/sec ±0.36%)
1044 minimatch ███████████████████████████████ (5,072 ops/sec ±0.83%)
1045 multimatch ███████████████████████████████ (5,028 ops/sec ±0.40%)
1047 micromatch is faster by an avg. of 158%
1049 # star-basename-short (349 bytes)
1050 micromatch ██████████████████████████████████████████████████ (269,552 ops/sec ±0.70%)
1051 minimatch ██████████████████████ (122,457 ops/sec ±1.39%)
1052 multimatch ████████████████████ (110,788 ops/sec ±1.99%)
1054 micromatch is faster by an avg. of 231%
1056 # star-folder-long (19207 bytes)
1057 micromatch █████████████████████████████████████████████████ (3,806 ops/sec ±0.38%)
1058 minimatch ████████████████████████████ (2,204 ops/sec ±0.32%)
1059 multimatch ██████████████████████████ (2,020 ops/sec ±1.07%)
1061 micromatch is faster by an avg. of 180%
1063 # star-folder-short (551 bytes)
1064 micromatch ██████████████████████████████████████████████████ (249,077 ops/sec ±0.40%)
1065 minimatch ███████████ (59,431 ops/sec ±1.67%)
1066 multimatch ███████████ (55,569 ops/sec ±1.43%)
1068 micromatch is faster by an avg. of 433%
1074 <summary><strong>Contributing</strong></summary>
1076 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
1078 Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
1083 <summary><strong>Running Tests</strong></summary>
1085 Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
1088 $ npm install && npm test
1094 <summary><strong>Building docs</strong></summary>
1096 _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
1098 To generate the readme, run the following command:
1101 $ npm install -g verbose/verb#dev verb-generate-readme && verb
1106 ### Related projects
1108 You might also be interested in these projects:
1110 * [braces](https://www.npmjs.com/package/braces): Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support… [more](https://github.com/micromatch/braces) | [homepage](https://github.com/micromatch/braces "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.")
1111 * [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/jonschlinkert/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.")
1112 * [extglob](https://www.npmjs.com/package/extglob): Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob… [more](https://github.com/micromatch/extglob) | [homepage](https://github.com/micromatch/extglob "Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.")
1113 * [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`")
1114 * [nanomatch](https://www.npmjs.com/package/nanomatch): Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash… [more](https://github.com/micromatch/nanomatch) | [homepage](https://github.com/micromatch/nanomatch "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)")
1118 | **Commits** | **Contributor** |
1120 | 457 | [jonschlinkert](https://github.com/jonschlinkert) |
1121 | 12 | [es128](https://github.com/es128) |
1122 | 8 | [doowb](https://github.com/doowb) |
1123 | 3 | [paulmillr](https://github.com/paulmillr) |
1124 | 2 | [TrySound](https://github.com/TrySound) |
1125 | 2 | [MartinKolarik](https://github.com/MartinKolarik) |
1126 | 2 | [charlike-old](https://github.com/charlike-old) |
1127 | 1 | [amilajack](https://github.com/amilajack) |
1128 | 1 | [mrmlnc](https://github.com/mrmlnc) |
1129 | 1 | [devongovett](https://github.com/devongovett) |
1130 | 1 | [DianeLooney](https://github.com/DianeLooney) |
1131 | 1 | [UltCombo](https://github.com/UltCombo) |
1132 | 1 | [tomByrer](https://github.com/tomByrer) |
1133 | 1 | [fidian](https://github.com/fidian) |
1139 * [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
1140 * [github/jonschlinkert](https://github.com/jonschlinkert)
1141 * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
1145 Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
1146 Released under the [MIT License](LICENSE).
1150 _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on February 18, 2018._