Debian Codegraph @

node/picomatch/README.md

raw
1 <h1 align="center">Picomatch</h1>
2
3 <p align="center">
4 <a href="https://npmjs.org/package/picomatch">
5 <img src="https://img.shields.io/npm/v/picomatch.svg" alt="version">
6 </a>
7 <a href="https://github.com/micromatch/picomatch/actions/workflows/test.yml">
8 <img src="https://github.com/micromatch/picomatch/actions/workflows/test.yml/badge.svg?branch=master" alt="test status">
9 </a>
10 <a href="https://coveralls.io/github/micromatch/picomatch">
11 <img src="https://img.shields.io/coveralls/github/micromatch/picomatch/master.svg" alt="coverage status">
12 </a>
13 <a href="https://npmjs.org/package/picomatch">
14 <img src="https://img.shields.io/npm/dm/picomatch" alt="downloads">
15 </a>
16 </p>
17
18 <br>
19 <br>
20
21 <p align="center">
22 <strong>Blazing fast and accurate glob matcher written in JavaScript.</strong></br>
23 <em>No dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.</em>
24 </p>
25
26 <br>
27 <br>
28
29 ## Why picomatch?
30
31 * **Lightweight** - No dependencies
32 * **Minimal** - Tiny API surface. Main export is a function that takes a glob pattern and returns a matcher function.
33 * **Fast** - Loads in about 2ms (that's several times faster than a [single frame of a HD movie](http://www.endmemo.com/sconvert/framespersecondframespermillisecond.php) at 60fps)
34 * **Performant** - Use the returned matcher function to speed up repeat matching (like when watching files)
35 * **Accurate matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories, [advanced globbing](#advanced-globbing) with extglobs, braces, and POSIX brackets, and support for escaping special characters with `\` or quotes.
36 * **Well tested** - Thousands of unit tests
37
38 See the [library comparison](#library-comparisons) to other libraries.
39
40 <br>
41 <br>
42
43 ## Table of Contents
44
45 <details><summary> Click to expand </summary>
46
47 - [Install](#install)
48 - [Usage](#usage)
49 - [API](#api)
50 * [picomatch](#picomatch)
51 * [.test](#test)
52 * [.matchBase](#matchbase)
53 * [.isMatch](#ismatch)
54 * [.parse](#parse)
55 * [.scan](#scan)
56 * [.compileRe](#compilere)
57 * [.makeRe](#makere)
58 * [.toRegex](#toregex)
59 - [Options](#options)
60 * [Picomatch options](#picomatch-options)
61 * [Scan Options](#scan-options)
62 * [Options Examples](#options-examples)
63 - [Globbing features](#globbing-features)
64 * [Basic globbing](#basic-globbing)
65 * [Advanced globbing](#advanced-globbing)
66 * [Braces](#braces)
67 * [Matching special characters as literals](#matching-special-characters-as-literals)
68 - [Library Comparisons](#library-comparisons)
69 - [Benchmarks](#benchmarks)
70 - [Philosophies](#philosophies)
71 - [About](#about)
72 * [Author](#author)
73 * [License](#license)
74
75 _(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
76
77 </details>
78
79 <br>
80 <br>
81
82 ## Install
83
84 Install with [npm](https://www.npmjs.com/):
85
86 ```sh
87 npm install --save picomatch
88 ```
89
90 <br>
91
92 ## Usage
93
94 The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.
95
96 ```js
97 const pm = require('picomatch');
98 const isMatch = pm('*.js');
99
100 console.log(isMatch('abcd')); //=> false
101 console.log(isMatch('a.js')); //=> true
102 console.log(isMatch('a.md')); //=> false
103 console.log(isMatch('a/b.js')); //=> false
104 ```
105
106 <br>
107
108 ## API
109
110 ### [picomatch](lib/picomatch.js#L43)
111
112 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.
113
114 **Params**
115
116 * `globs` **{String|Array}**: One or more glob patterns.
117 * `options` **{Object=}**
118 * `returns` **{Function=}**: Returns a matcher function.
119
120 **Example**
121
122 ```js
123 const picomatch = require('picomatch');
124 // picomatch(glob[, options]);
125
126 const isMatch = picomatch('*.!(*a)');
127 console.log(isMatch('a.a')); //=> false
128 console.log(isMatch('a.b')); //=> true
129
130 // For environments without `node.js`, `picomatch/posix` provides you a dependency-free matcher, without automatic OS detection.
131 const picomatch = require('picomatch/posix');
132 // the same API, defaulting to posix paths
133 const isMatch = picomatch('a/*');
134 console.log(isMatch('a\\b')); //=> false
135 console.log(isMatch('a/b')); //=> true
136
137 // you can still configure the matcher function to accept windows paths
138 const isMatch = picomatch('a/*', { options: windows });
139 console.log(isMatch('a\\b')); //=> true
140 console.log(isMatch('a/b')); //=> true
141 ```
142
143 ### [.test](lib/picomatch.js#L128)
144
145 Test `input` with the given `regex`. This is used by the main `picomatch()` function to test the input string.
146
147 **Params**
148
149 * `input` **{String}**: String to test.
150 * `regex` **{RegExp}**
151 * `returns` **{Object}**: Returns an object with matching info.
152
153 **Example**
154
155 ```js
156 const picomatch = require('picomatch');
157 // picomatch.test(input, regex[, options]);
158
159 console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
160 // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
161 ```
162
163 ### [.matchBase](lib/picomatch.js#L172)
164
165 Match the basename of a filepath.
166
167 **Params**
168
169 * `input` **{String}**: String to test.
170 * `glob` **{RegExp|String}**: Glob pattern or regex created by [.makeRe](#makeRe).
171 * `returns` **{Boolean}**
172
173 **Example**
174
175 ```js
176 const picomatch = require('picomatch');
177 // picomatch.matchBase(input, glob[, options]);
178 console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
179 ```
180
181 ### [.isMatch](lib/picomatch.js#L194)
182
183 Returns true if **any** of the given glob `patterns` match the specified `string`.
184
185 **Params**
186
187 * **{String|Array}**: str The string to test.
188 * **{String|Array}**: patterns One or more glob patterns to use for matching.
189 * **{Object}**: See available [options](#options).
190 * `returns` **{Boolean}**: Returns true if any patterns match `str`
191
192 **Example**
193
194 ```js
195 const picomatch = require('picomatch');
196 // picomatch.isMatch(string, patterns[, options]);
197
198 console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
199 console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
200 ```
201
202 ### [.parse](lib/picomatch.js#L210)
203
204 Parse a glob pattern to create the source string for a regular expression.
205
206 **Params**
207
208 * `pattern` **{String}**
209 * `options` **{Object}**
210 * `returns` **{Object}**: Returns an object with useful properties and output to be used as a regex source string.
211
212 **Example**
213
214 ```js
215 const picomatch = require('picomatch');
216 const result = picomatch.parse(pattern[, options]);
217 ```
218
219 ### [.scan](lib/picomatch.js#L242)
220
221 Scan a glob pattern to separate the pattern into segments.
222
223 **Params**
224
225 * `input` **{String}**: Glob pattern to scan.
226 * `options` **{Object}**
227 * `returns` **{Object}**: Returns an object with
228
229 **Example**
230
231 ```js
232 const picomatch = require('picomatch');
233 // picomatch.scan(input[, options]);
234
235 const result = picomatch.scan('!./foo/*.js');
236 console.log(result);
237 { prefix: '!./',
238 input: '!./foo/*.js',
239 start: 3,
240 base: 'foo',
241 glob: '*.js',
242 isBrace: false,
243 isBracket: false,
244 isGlob: true,
245 isExtglob: false,
246 isGlobstar: false,
247 negated: true }
248 ```
249
250 ### [.compileRe](lib/picomatch.js#L264)
251
252 Compile a regular expression from the `state` object returned by the [parse()](#parse) method.
253
254 **Params**
255
256 * `state` **{Object}**
257 * `options` **{Object}**
258 * `returnOutput` **{Boolean}**: Intended for implementors, this argument allows you to return the raw output from the parser.
259 * `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
260 * `returns` **{RegExp}**
261
262 **Example**
263
264 ```js
265 const picomatch = require('picomatch');
266 const state = picomatch.parse('*.js');
267 // picomatch.compileRe(state[, options]);
268
269 console.log(picomatch.compileRe(state));
270 //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
271 ```
272
273 ### [.makeRe](lib/picomatch.js#L305)
274
275 Create a regular expression from a parsed glob pattern.
276
277 **Params**
278
279 * `state` **{String}**: The object returned from the `.parse` method.
280 * `options` **{Object}**
281 * `returnOutput` **{Boolean}**: Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
282 * `returnState` **{Boolean}**: Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
283 * `returns` **{RegExp}**: Returns a regex created from the given pattern.
284
285 **Example**
286
287 ```js
288 const picomatch = require('picomatch');
289 // picomatch.makeRe(state[, options]);
290
291 const result = picomatch.makeRe('*.js');
292 console.log(result);
293 //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
294 ```
295
296 ### [.toRegex](lib/picomatch.js#L340)
297
298 Create a regular expression from the given regex source string.
299
300 **Params**
301
302 * `source` **{String}**: Regular expression source string.
303 * `options` **{Object}**
304 * `returns` **{RegExp}**
305
306 **Example**
307
308 ```js
309 const picomatch = require('picomatch');
310 // picomatch.toRegex(source[, options]);
311
312 const { output } = picomatch.parse('*.js');
313 console.log(picomatch.toRegex(output));
314 //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
315 ```
316
317 <br>
318
319 ## Options
320
321 ### Picomatch options
322
323 The following options may be used with the main `picomatch()` function or any of the methods on the picomatch API.
324
325 | **Option** | **Type** | **Default value** | **Description** |
326 | --- | --- | --- | --- |
327 | `basename` | `boolean` | `false` | If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`. |
328 | `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |
329 | `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |
330 | `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |
331 | `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |
332 | `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |
333 | `expandRange` | `function` | `undefined` | Custom function for expanding ranges in brace patterns, such as `{a..z}`. The function receives the range values as two arguments, and it must return a string to be used in the generated regex. It's recommended that returned strings be wrapped in parentheses. |
334 | `fastpaths` | `boolean` | `true` | To speed up processing, full parsing is skipped for a handful common glob patterns. Disable this behavior by setting this option to `false`. |
335 | `flags` | `string` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
336 | [format](#optionsformat) | `function` | `undefined` | Custom function for formatting the returned string. This is useful for removing leading slashes, converting Windows paths to Posix paths, etc. |
337 | `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. |
338 | `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. |
339 | `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
340 | `matchBase` | `boolean` | `false` | Alias for `basename` |
341 | `maxLength` | `number` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
342 | `maxExtglobRecursion` | `number\|boolean` | `0` | Limit nested quantified extglobs and other risky repeated extglob forms. When the limit is exceeded, the extglob is treated as a literal string instead of being compiled to regex. Set to `false` to disable this safeguard. |
343 | `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
344 | `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |
345 | `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |
346 | `noext` | `boolean` | `false` | Alias for `noextglob` |
347 | `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |
348 | `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |
349 | `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |
350 | [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |
351 | [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |
352 | [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
353 | `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |
354 | `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |
355 | `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
356 | `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
357 | `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
358 | `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
359 | `windows` | `boolean` | `false` | Also accept backslashes as the path separator. |
360
361 ### Scan Options
362
363 In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.
364
365 | **Option** | **Type** | **Default value** | **Description** |
366 | --- | --- | --- | --- |
367 | `tokens` | `boolean` | `false` | When `true`, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern |
368 | `parts` | `boolean` | `false` | When `true`, the returned object will include an array of strings representing each path "segment" in the scanned glob pattern. This is automatically enabled when `options.tokens` is true |
369
370 **Example**
371
372 ```js
373 const picomatch = require('picomatch');
374 const result = picomatch.scan('!./foo/*.js', { tokens: true });
375 console.log(result);
376 // {
377 // prefix: '!./',
378 // input: '!./foo/*.js',
379 // start: 3,
380 // base: 'foo',
381 // glob: '*.js',
382 // isBrace: false,
383 // isBracket: false,
384 // isGlob: true,
385 // isExtglob: false,
386 // isGlobstar: false,
387 // negated: true,
388 // maxDepth: 2,
389 // tokens: [
390 // { value: '!./', depth: 0, isGlob: false, negated: true, isPrefix: true },
391 // { value: 'foo', depth: 1, isGlob: false },
392 // { value: '*.js', depth: 1, isGlob: true }
393 // ],
394 // slashes: [ 2, 6 ],
395 // parts: [ 'foo', '*.js' ]
396 // }
397 ```
398
399 <br>
400
401 ### Options Examples
402
403 #### options.expandRange
404
405 **Type**: `function`
406
407 **Default**: `undefined`
408
409 Custom function for expanding ranges in brace patterns. The [fill-range](https://github.com/jonschlinkert/fill-range) library is ideal for this purpose, or you can use custom code to do whatever you need.
410
411 **Example**
412
413 The following example shows how to create a glob that matches a folder
414
415 ```js
416 const fill = require('fill-range');
417 const regex = pm.makeRe('foo/{01..25}/bar', {
418 expandRange(a, b) {
419 return `(${fill(a, b, { toRegex: true })})`;
420 }
421 });
422
423 console.log(regex);
424 //=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/
425
426 console.log(regex.test('foo/00/bar')) // false
427 console.log(regex.test('foo/01/bar')) // true
428 console.log(regex.test('foo/10/bar')) // true
429 console.log(regex.test('foo/22/bar')) // true
430 console.log(regex.test('foo/25/bar')) // true
431 console.log(regex.test('foo/26/bar')) // false
432 ```
433
434 #### options.format
435
436 **Type**: `function`
437
438 **Default**: `undefined`
439
440 Custom function for formatting strings before they're matched.
441
442 **Example**
443
444 ```js
445 // strip leading './' from strings
446 const format = str => str.replace(/^\.\//, '');
447 const isMatch = picomatch('foo/*.js', { format });
448 console.log(isMatch('./foo/bar.js')); //=> true
449 ```
450
451 #### options.onMatch
452
453 ```js
454 const onMatch = ({ glob, regex, input, output }) => {
455 console.log({ glob, regex, input, output });
456 };
457
458 const isMatch = picomatch('*', { onMatch });
459 isMatch('foo');
460 isMatch('bar');
461 isMatch('baz');
462 ```
463
464 #### options.onIgnore
465
466 ```js
467 const onIgnore = ({ glob, regex, input, output }) => {
468 console.log({ glob, regex, input, output });
469 };
470
471 const isMatch = picomatch('*', { onIgnore, ignore: 'f*' });
472 isMatch('foo');
473 isMatch('bar');
474 isMatch('baz');
475 ```
476
477 #### options.onResult
478
479 ```js
480 const onResult = ({ glob, regex, input, output }) => {
481 console.log({ glob, regex, input, output });
482 };
483
484 const isMatch = picomatch('*', { onResult, ignore: 'f*' });
485 isMatch('foo');
486 isMatch('bar');
487 isMatch('baz');
488 ```
489
490 <br>
491 <br>
492
493 ## Globbing features
494
495 * [Basic globbing](#basic-globbing) (Wildcard matching)
496 * [Advanced globbing](#advanced-globbing) (extglobs, posix brackets, brace matching)
497
498 ### Basic globbing
499
500 | **Character** | **Description** |
501 | --- | --- |
502 | `*` | Matches any character zero or more times, excluding path separators. Does _not match_ path separators or hidden files or directories ("dotfiles"), unless explicitly enabled by setting the `dot` option to `true`. |
503 | `**` | Matches any character zero or more times, including path separators. Note that `**` will only match path separators (`/`, and `\\` with the `windows` option) when they are the only characters in a path segment. Thus, `foo**/bar` is equivalent to `foo*/bar`, and `foo/a**b/bar` is equivalent to `foo/a*b/bar`, and _more than two_ consecutive stars in a glob path segment are regarded as _a single star_. Thus, `foo/***/bar` is equivalent to `foo/*/bar`. |
504 | `?` | Matches any character excluding path separators one time. Does _not match_ path separators or leading dots. |
505 | `[abc]` | Matches any characters inside the brackets. For example, `[abc]` would match the characters `a`, `b` or `c`, and nothing else. |
506
507 #### Matching behavior vs. Bash
508
509 Picomatch's matching features and expected results in unit tests are based on Bash's unit tests and the Bash 4.3 specification, with the following exceptions:
510
511 * Bash will match `foo/bar/baz` with `*`. Picomatch only matches nested directories with `**`.
512 * Bash greedily matches with negated extglobs. For example, Bash 4.3 says that `!(foo)*` should match `foo` and `foobar`, since the trailing `*` bracktracks to match the preceding pattern. This is very memory-inefficient, and IMHO, also incorrect. Picomatch would return `false` for both `foo` and `foobar`.
513
514 <br>
515
516 ### Advanced globbing
517
518 * [extglobs](#extglobs)
519 * [POSIX brackets](#posix-brackets)
520 * [Braces](#brace-expansion)
521
522 #### Extglobs
523
524 | **Pattern** | **Description** |
525 | --- | --- |
526 | `@(pattern)` | Match _only one_ consecutive occurrence of `pattern` |
527 | `*(pattern)` | Match _zero or more_ consecutive occurrences of `pattern` |
528 | `+(pattern)` | Match _one or more_ consecutive occurrences of `pattern` |
529 | `?(pattern)` | Match _zero or **one**_ consecutive occurrences of `pattern` |
530 | `!(pattern)` | Match _anything but_ `pattern` |
531
532 **Examples**
533
534 ```js
535 const pm = require('picomatch');
536
537 // *(pattern) matches ZERO or more of "pattern"
538 console.log(pm.isMatch('a', 'a*(z)')); // true
539 console.log(pm.isMatch('az', 'a*(z)')); // true
540 console.log(pm.isMatch('azzz', 'a*(z)')); // true
541
542 // +(pattern) matches ONE or more of "pattern"
543 console.log(pm.isMatch('a', 'a+(z)')); // false
544 console.log(pm.isMatch('az', 'a+(z)')); // true
545 console.log(pm.isMatch('azzz', 'a+(z)')); // true
546
547 // supports multiple extglobs
548 console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
549
550 // supports nested extglobs
551 console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
552
553 // risky quantified extglobs are treated literally by default
554 console.log(pm.makeRe('+(a|aa)'));
555 //=> /^(?:\+\(a\|aa\))$/
556
557 // increase the limit to allow a small amount of nested quantified extglobs
558 console.log(pm.isMatch('aaa', '+(+(a))', { maxExtglobRecursion: 1 })); // true
559 ```
560
561 #### POSIX brackets
562
563 POSIX classes are disabled by default. Enable this feature by setting the `posix` option to true.
564
565 **Enable POSIX bracket support**
566
567 ```js
568 console.log(pm.makeRe('[[:word:]]+', { posix: true }));
569 //=> /^(?:(?=.)[A-Za-z0-9_]+\/?)$/
570 ```
571
572 **Supported POSIX classes**
573
574 The following named POSIX bracket expressions are supported:
575
576 * `[:alnum:]` - Alphanumeric characters, equ `[a-zA-Z0-9]`
577 * `[:alpha:]` - Alphabetical characters, equivalent to `[a-zA-Z]`.
578 * `[:ascii:]` - ASCII characters, equivalent to `[\\x00-\\x7F]`.
579 * `[:blank:]` - Space and tab characters, equivalent to `[ \\t]`.
580 * `[:cntrl:]` - Control characters, equivalent to `[\\x00-\\x1F\\x7F]`.
581 * `[:digit:]` - Numerical digits, equivalent to `[0-9]`.
582 * `[:graph:]` - Graph characters, equivalent to `[\\x21-\\x7E]`.
583 * `[:lower:]` - Lowercase letters, equivalent to `[a-z]`.
584 * `[:print:]` - Print characters, equivalent to `[\\x20-\\x7E ]`.
585 * `[:punct:]` - Punctuation and symbols, equivalent to `[\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~]`.
586 * `[:space:]` - Extended space characters, equivalent to `[ \\t\\r\\n\\v\\f]`.
587 * `[:upper:]` - Uppercase letters, equivalent to `[A-Z]`.
588 * `[:word:]` - Word characters (letters, numbers and underscores), equivalent to `[A-Za-z0-9_]`.
589 * `[:xdigit:]` - Hexadecimal digits, equivalent to `[A-Fa-f0-9]`.
590
591 See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html) for more information.
592
593 ### Braces
594
595 Picomatch only does [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) of comma-delimited lists (e.g. `a/{b,c}/d`). For advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch), which supports advanced syntax such as ranges (e.g. `{01..03}`) and increments (e.g. `{2..10..2}`).
596
597 ### Matching special characters as literals
598
599 If you wish to match the following special characters in a filepath, and you want to use these characters in your glob pattern, they must be escaped with backslashes or quotes:
600
601 **Special Characters**
602
603 Some characters that are used for matching in regular expressions are also regarded as valid file path characters on some platforms.
604
605 To match any of the following characters as literals: `$^*+?()[]
606
607 Examples:
608
609 ```js
610 console.log(pm.makeRe('foo/bar \\(1\\)'));
611 console.log(pm.makeRe('foo/bar \\(1\\)'));
612 ```
613
614 <br>
615 <br>
616
617 ## Library Comparisons
618
619 The following table shows which features are supported by [minimatch](https://github.com/isaacs/minimatch), [micromatch](https://github.com/micromatch/micromatch), [picomatch](https://github.com/micromatch/picomatch), [nanomatch](https://github.com/micromatch/nanomatch), [extglob](https://github.com/micromatch/extglob), [braces](https://github.com/micromatch/braces), and [expand-brackets](https://github.com/micromatch/expand-brackets).
620
621 | **Feature** | `minimatch` | `micromatch` | `picomatch` | `nanomatch` | `extglob` | `braces` | `expand-brackets` |
622 | --- | --- | --- | --- | --- | --- | --- | --- |
623 | Wildcard matching (`*?+`) | ✔ | ✔ | ✔ | ✔ | - | - | - |
624 | Advancing globbing | ✔ | ✔ | ✔ | - | - | - | - |
625 | Brace _matching_ | ✔ | ✔ | ✔ | - | - | ✔ | - |
626 | Brace _expansion_ | ✔ | ✔ | - | - | - | ✔ | - |
627 | Extglobs | partial | ✔ | ✔ | - | ✔ | - | - |
628 | Posix brackets | - | ✔ | ✔ | - | - | - | ✔ |
629 | Regular expression syntax | - | ✔ | ✔ | ✔ | ✔ | - | ✔ |
630 | File system operations | - | - | - | - | - | - | - |
631
632 <br>
633 <br>
634
635 ## Benchmarks
636
637 Performance comparison of picomatch and minimatch.
638
639 ```
640 # .makeRe star (*)
641 picomatch x 3,251,247 ops/sec ±0.25% (95 runs sampled)
642 minimatch x 497,224 ops/sec ±0.11% (100 runs sampled)
643
644 # .makeRe star; dot=true (*)
645 picomatch x 2,624,035 ops/sec ±0.16% (98 runs sampled)
646 minimatch x 446,244 ops/sec ±0.63% (99 runs sampled)
647
648 # .makeRe globstar (**)
649 picomatch x 2,524,465 ops/sec ±0.13% (99 runs sampled)
650 minimatch x 1,396,257 ops/sec ±0.58% (96 runs sampled)
651
652 # .makeRe globstars (**/**/**)
653 picomatch x 2,545,674 ops/sec ±0.10% (99 runs sampled)
654 minimatch x 1,196,835 ops/sec ±0.63% (98 runs sampled)
655
656 # .makeRe with leading star (*.txt)
657 picomatch x 2,537,708 ops/sec ±0.11% (100 runs sampled)
658 minimatch x 345,284 ops/sec ±0.64% (96 runs sampled)
659
660 # .makeRe - basic braces ({a,b,c}*.txt)
661 picomatch x 505,430 ops/sec ±1.04% (94 runs sampled)
662 minimatch x 107,991 ops/sec ±0.54% (99 runs sampled)
663
664 # .makeRe - short ranges ({a..z}*.txt)
665 picomatch x 371,179 ops/sec ±2.91% (77 runs sampled)
666 minimatch x 14,104 ops/sec ±0.61% (99 runs sampled)
667
668 # .makeRe - medium ranges ({1..100000}*.txt)
669 picomatch x 384,958 ops/sec ±1.70% (82 runs sampled)
670 minimatch x 2.55 ops/sec ±3.22% (11 runs sampled)
671
672 # .makeRe - long ranges ({1..10000000}*.txt)
673 picomatch x 382,552 ops/sec ±1.52% (71 runs sampled)
674 minimatch x 0.83 ops/sec ±5.67% (7 runs sampled))
675 ```
676
677 <br>
678 <br>
679
680 ## Philosophies
681
682 The goal of this library is to be blazing fast, without compromising on accuracy.
683
684 **Accuracy**
685
686 The number one of goal of this library is accuracy. However, it's not unusual for different glob implementations to have different rules for matching behavior, even with simple wildcard matching. It gets increasingly more complicated when combinations of different features are combined, like when extglobs are combined with globstars, braces, slashes, and so on: `!(**/{a,b,*/c})`.
687
688 Thus, given that there is no canonical glob specification to use as a single source of truth when differences of opinion arise regarding behavior, sometimes we have to implement our best judgement and rely on feedback from users to make improvements.
689
690 **Performance**
691
692 Although this library performs well in benchmarks, and in most cases it's faster than other popular libraries we benchmarked against, we will always choose accuracy over performance. It's not helpful to anyone if our library is faster at returning the wrong answer.
693
694 <br>
695 <br>
696
697 ## About
698
699 <details>
700 <summary><strong>Contributing</strong></summary>
701
702 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
703
704 Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
705
706 </details>
707
708 <details>
709 <summary><strong>Running Tests</strong></summary>
710
711 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:
712
713 ```sh
714 npm install && npm test
715 ```
716
717 </details>
718
719 <details>
720 <summary><strong>Building docs</strong></summary>
721
722 _(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.)_
723
724 To generate the readme, run the following command:
725
726 ```sh
727 npm install -g verbose/verb#dev verb-generate-readme && verb
728 ```
729
730 </details>
731
732 ### Author
733
734 **Jon Schlinkert**
735
736 * [GitHub Profile](https://github.com/jonschlinkert)
737 * [Twitter Profile](https://twitter.com/jonschlinkert)
738 * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
739
740 ### License
741
742 Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
743 Released under the [MIT License](LICENSE).