Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <h1 align="center">Picomatch</h1>
  2. <p align="center">
  3. <a href="https://npmjs.org/package/picomatch">
  4. <img src="https://img.shields.io/npm/v/picomatch.svg" alt="version">
  5. </a>
  6. <a href="https://github.com/micromatch/picomatch/actions?workflow=Tests">
  7. <img src="https://github.com/micromatch/picomatch/workflows/Tests/badge.svg" alt="test status">
  8. </a>
  9. <a href="https://coveralls.io/github/micromatch/picomatch">
  10. <img src="https://img.shields.io/coveralls/github/micromatch/picomatch/master.svg" alt="coverage status">
  11. </a>
  12. <a href="https://npmjs.org/package/picomatch">
  13. <img src="https://img.shields.io/npm/dm/picomatch.svg" alt="downloads">
  14. </a>
  15. </p>
  16. <br>
  17. <br>
  18. <p align="center">
  19. <strong>Blazing fast and accurate glob matcher written in JavaScript.</strong></br>
  20. <em>No dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.</em>
  21. </p>
  22. <br>
  23. <br>
  24. ## Why picomatch?
  25. * **Lightweight** - No dependencies
  26. * **Minimal** - Tiny API surface. Main export is a function that takes a glob pattern and returns a matcher function.
  27. * **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)
  28. * **Performant** - Use the returned matcher function to speed up repeat matching (like when watching files)
  29. * **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.
  30. * **Well tested** - Thousands of unit tests
  31. See the [library comparison](#library-comparisons) to other libraries.
  32. <br>
  33. <br>
  34. ## Table of Contents
  35. <details><summary> Click to expand </summary>
  36. - [Install](#install)
  37. - [Usage](#usage)
  38. - [API](#api)
  39. * [picomatch](#picomatch)
  40. * [.test](#test)
  41. * [.matchBase](#matchbase)
  42. * [.isMatch](#ismatch)
  43. * [.parse](#parse)
  44. * [.scan](#scan)
  45. * [.compileRe](#compilere)
  46. * [.makeRe](#makere)
  47. * [.toRegex](#toregex)
  48. - [Options](#options)
  49. * [Picomatch options](#picomatch-options)
  50. * [Scan Options](#scan-options)
  51. * [Options Examples](#options-examples)
  52. - [Globbing features](#globbing-features)
  53. * [Basic globbing](#basic-globbing)
  54. * [Advanced globbing](#advanced-globbing)
  55. * [Braces](#braces)
  56. * [Matching special characters as literals](#matching-special-characters-as-literals)
  57. - [Library Comparisons](#library-comparisons)
  58. - [Benchmarks](#benchmarks)
  59. - [Philosophies](#philosophies)
  60. - [About](#about)
  61. * [Author](#author)
  62. * [License](#license)
  63. _(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
  64. </details>
  65. <br>
  66. <br>
  67. ## Install
  68. Install with [npm](https://www.npmjs.com/):
  69. ```sh
  70. npm install --save picomatch
  71. ```
  72. <br>
  73. ## Usage
  74. The main export is a function that takes a glob pattern and an options object and returns a function for matching strings.
  75. ```js
  76. const pm = require('picomatch');
  77. const isMatch = pm('*.js');
  78. console.log(isMatch('abcd')); //=> false
  79. console.log(isMatch('a.js')); //=> true
  80. console.log(isMatch('a.md')); //=> false
  81. console.log(isMatch('a/b.js')); //=> false
  82. ```
  83. <br>
  84. ## API
  85. ### [picomatch](lib/picomatch.js#L32)
  86. 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.
  87. **Params**
  88. * `globs` **{String|Array}**: One or more glob patterns.
  89. * `options` **{Object=}**
  90. * `returns` **{Function=}**: Returns a matcher function.
  91. **Example**
  92. ```js
  93. const picomatch = require('picomatch');
  94. // picomatch(glob[, options]);
  95. const isMatch = picomatch('*.!(*a)');
  96. console.log(isMatch('a.a')); //=> false
  97. console.log(isMatch('a.b')); //=> true
  98. ```
  99. ### [.test](lib/picomatch.js#L117)
  100. Test `input` with the given `regex`. This is used by the main `picomatch()` function to test the input string.
  101. **Params**
  102. * `input` **{String}**: String to test.
  103. * `regex` **{RegExp}**
  104. * `returns` **{Object}**: Returns an object with matching info.
  105. **Example**
  106. ```js
  107. const picomatch = require('picomatch');
  108. // picomatch.test(input, regex[, options]);
  109. console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
  110. // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
  111. ```
  112. ### [.matchBase](lib/picomatch.js#L161)
  113. Match the basename of a filepath.
  114. **Params**
  115. * `input` **{String}**: String to test.
  116. * `glob` **{RegExp|String}**: Glob pattern or regex created by [.makeRe](#makeRe).
  117. * `returns` **{Boolean}**
  118. **Example**
  119. ```js
  120. const picomatch = require('picomatch');
  121. // picomatch.matchBase(input, glob[, options]);
  122. console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
  123. ```
  124. ### [.isMatch](lib/picomatch.js#L183)
  125. Returns true if **any** of the given glob `patterns` match the specified `string`.
  126. **Params**
  127. * **{String|Array}**: str The string to test.
  128. * **{String|Array}**: patterns One or more glob patterns to use for matching.
  129. * **{Object}**: See available [options](#options).
  130. * `returns` **{Boolean}**: Returns true if any patterns match `str`
  131. **Example**
  132. ```js
  133. const picomatch = require('picomatch');
  134. // picomatch.isMatch(string, patterns[, options]);
  135. console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
  136. console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
  137. ```
  138. ### [.parse](lib/picomatch.js#L199)
  139. Parse a glob pattern to create the source string for a regular expression.
  140. **Params**
  141. * `pattern` **{String}**
  142. * `options` **{Object}**
  143. * `returns` **{Object}**: Returns an object with useful properties and output to be used as a regex source string.
  144. **Example**
  145. ```js
  146. const picomatch = require('picomatch');
  147. const result = picomatch.parse(pattern[, options]);
  148. ```
  149. ### [.scan](lib/picomatch.js#L231)
  150. Scan a glob pattern to separate the pattern into segments.
  151. **Params**
  152. * `input` **{String}**: Glob pattern to scan.
  153. * `options` **{Object}**
  154. * `returns` **{Object}**: Returns an object with
  155. **Example**
  156. ```js
  157. const picomatch = require('picomatch');
  158. // picomatch.scan(input[, options]);
  159. const result = picomatch.scan('!./foo/*.js');
  160. console.log(result);
  161. { prefix: '!./',
  162. input: '!./foo/*.js',
  163. start: 3,
  164. base: 'foo',
  165. glob: '*.js',
  166. isBrace: false,
  167. isBracket: false,
  168. isGlob: true,
  169. isExtglob: false,
  170. isGlobstar: false,
  171. negated: true }
  172. ```
  173. ### [.compileRe](lib/picomatch.js#L245)
  174. Compile a regular expression from the `state` object returned by the
  175. [parse()](#parse) method.
  176. **Params**
  177. * `state` **{Object}**
  178. * `options` **{Object}**
  179. * `returnOutput` **{Boolean}**: Intended for implementors, this argument allows you to return the raw output from the parser.
  180. * `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
  181. * `returns` **{RegExp}**
  182. ### [.makeRe](lib/picomatch.js#L286)
  183. Create a regular expression from a parsed glob pattern.
  184. **Params**
  185. * `state` **{String}**: The object returned from the `.parse` method.
  186. * `options` **{Object}**
  187. * `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.
  188. * `returnState` **{Boolean}**: Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
  189. * `returns` **{RegExp}**: Returns a regex created from the given pattern.
  190. **Example**
  191. ```js
  192. const picomatch = require('picomatch');
  193. const state = picomatch.parse('*.js');
  194. // picomatch.compileRe(state[, options]);
  195. console.log(picomatch.compileRe(state));
  196. //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  197. ```
  198. ### [.toRegex](lib/picomatch.js#L321)
  199. Create a regular expression from the given regex source string.
  200. **Params**
  201. * `source` **{String}**: Regular expression source string.
  202. * `options` **{Object}**
  203. * `returns` **{RegExp}**
  204. **Example**
  205. ```js
  206. const picomatch = require('picomatch');
  207. // picomatch.toRegex(source[, options]);
  208. const { output } = picomatch.parse('*.js');
  209. console.log(picomatch.toRegex(output));
  210. //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
  211. ```
  212. <br>
  213. ## Options
  214. ### Picomatch options
  215. The following options may be used with the main `picomatch()` function or any of the methods on the picomatch API.
  216. | **Option** | **Type** | **Default value** | **Description** |
  217. | --- | --- | --- | --- |
  218. | `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`. |
  219. | `bash` | `boolean` | `false` | Follow bash matching rules more strictly - disallows backslashes as escape characters, and treats single stars as globstars (`**`). |
  220. | `capture` | `boolean` | `undefined` | Return regex matches in supporting methods. |
  221. | `contains` | `boolean` | `undefined` | Allows glob to match any part of the given string(s). |
  222. | `cwd` | `string` | `process.cwd()` | Current working directory. Used by `picomatch.split()` |
  223. | `debug` | `boolean` | `undefined` | Debug regular expressions when an error is thrown. |
  224. | `dot` | `boolean` | `false` | Enable dotfile matching. By default, dotfiles are ignored unless a `.` is explicitly defined in the pattern, or `options.dot` is true |
  225. | `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. |
  226. | `failglob` | `boolean` | `false` | Throws an error if no matches are found. Based on the bash option of the same name. |
  227. | `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`. |
  228. | `flags` | `boolean` | `undefined` | Regex flags to use in the generated regex. If defined, the `nocase` option will be overridden. |
  229. | [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. |
  230. | `ignore` | `array\|string` | `undefined` | One or more glob patterns for excluding strings that should not be matched from the result. |
  231. | `keepQuotes` | `boolean` | `false` | Retain quotes in the generated regex, since quotes may also be used as an alternative to backslashes. |
  232. | `literalBrackets` | `boolean` | `undefined` | When `true`, brackets in the glob pattern will be escaped so that only literal brackets will be matched. |
  233. | `lookbehinds` | `boolean` | `true` | Support regex positive and negative lookbehinds. Note that you must be using Node 8.1.10 or higher to enable regex lookbehinds. |
  234. | `matchBase` | `boolean` | `false` | Alias for `basename` |
  235. | `maxLength` | `boolean` | `65536` | Limit the max length of the input string. An error is thrown if the input string is longer than this value. |
  236. | `nobrace` | `boolean` | `false` | Disable brace matching, so that `{a,b}` and `{1..3}` would be treated as literal characters. |
  237. | `nobracket` | `boolean` | `undefined` | Disable matching with regex brackets. |
  238. | `nocase` | `boolean` | `false` | Make matching case-insensitive. Equivalent to the regex `i` flag. Note that this option is overridden by the `flags` option. |
  239. | `nodupes` | `boolean` | `true` | Deprecated, use `nounique` instead. This option will be removed in a future major release. By default duplicates are removed. Disable uniquification by setting this option to false. |
  240. | `noext` | `boolean` | `false` | Alias for `noextglob` |
  241. | `noextglob` | `boolean` | `false` | Disable support for matching with extglobs (like `+(a\|b)`) |
  242. | `noglobstar` | `boolean` | `false` | Disable support for matching nested directories with globstars (`**`) |
  243. | `nonegate` | `boolean` | `false` | Disable support for negating with leading `!` |
  244. | `noquantifiers` | `boolean` | `false` | Disable support for regex quantifiers (like `a{1,2}`) and treat them as brace patterns to be expanded. |
  245. | [onIgnore](#optionsonIgnore) | `function` | `undefined` | Function to be called on ignored items. |
  246. | [onMatch](#optionsonMatch) | `function` | `undefined` | Function to be called on matched items. |
  247. | [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
  248. | `posix` | `boolean` | `false` | Support POSIX character classes ("posix brackets"). |
  249. | `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself |
  250. | `prepend` | `boolean` | `undefined` | String to prepend to the generated regex used for matching. |
  251. | `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
  252. | `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
  253. | `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
  254. | `unescape` | `boolean` | `undefined` | Remove backslashes preceding escaped characters in the glob pattern. By default, backslashes are retained. |
  255. | `unixify` | `boolean` | `undefined` | Alias for `posixSlashes`, for backwards compatibility. |
  256. ### Scan Options
  257. In addition to the main [picomatch options](#picomatch-options), the following options may also be used with the [.scan](#scan) method.
  258. | **Option** | **Type** | **Default value** | **Description** |
  259. | --- | --- | --- | --- |
  260. | `tokens` | `boolean` | `false` | When `true`, the returned object will include an array of tokens (objects), representing each path "segment" in the scanned glob pattern |
  261. | `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 |
  262. **Example**
  263. ```js
  264. const picomatch = require('picomatch');
  265. const result = picomatch.scan('!./foo/*.js', { tokens: true });
  266. console.log(result);
  267. // {
  268. // prefix: '!./',
  269. // input: '!./foo/*.js',
  270. // start: 3,
  271. // base: 'foo',
  272. // glob: '*.js',
  273. // isBrace: false,
  274. // isBracket: false,
  275. // isGlob: true,
  276. // isExtglob: false,
  277. // isGlobstar: false,
  278. // negated: true,
  279. // maxDepth: 2,
  280. // tokens: [
  281. // { value: '!./', depth: 0, isGlob: false, negated: true, isPrefix: true },
  282. // { value: 'foo', depth: 1, isGlob: false },
  283. // { value: '*.js', depth: 1, isGlob: true }
  284. // ],
  285. // slashes: [ 2, 6 ],
  286. // parts: [ 'foo', '*.js' ]
  287. // }
  288. ```
  289. <br>
  290. ### Options Examples
  291. #### options.expandRange
  292. **Type**: `function`
  293. **Default**: `undefined`
  294. 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.
  295. **Example**
  296. The following example shows how to create a glob that matches a folder
  297. ```js
  298. const fill = require('fill-range');
  299. const regex = pm.makeRe('foo/{01..25}/bar', {
  300. expandRange(a, b) {
  301. return `(${fill(a, b, { toRegex: true })})`;
  302. }
  303. });
  304. console.log(regex);
  305. //=> /^(?:foo\/((?:0[1-9]|1[0-9]|2[0-5]))\/bar)$/
  306. console.log(regex.test('foo/00/bar')) // false
  307. console.log(regex.test('foo/01/bar')) // true
  308. console.log(regex.test('foo/10/bar')) // true
  309. console.log(regex.test('foo/22/bar')) // true
  310. console.log(regex.test('foo/25/bar')) // true
  311. console.log(regex.test('foo/26/bar')) // false
  312. ```
  313. #### options.format
  314. **Type**: `function`
  315. **Default**: `undefined`
  316. Custom function for formatting strings before they're matched.
  317. **Example**
  318. ```js
  319. // strip leading './' from strings
  320. const format = str => str.replace(/^\.\//, '');
  321. const isMatch = picomatch('foo/*.js', { format });
  322. console.log(isMatch('./foo/bar.js')); //=> true
  323. ```
  324. #### options.onMatch
  325. ```js
  326. const onMatch = ({ glob, regex, input, output }) => {
  327. console.log({ glob, regex, input, output });
  328. };
  329. const isMatch = picomatch('*', { onMatch });
  330. isMatch('foo');
  331. isMatch('bar');
  332. isMatch('baz');
  333. ```
  334. #### options.onIgnore
  335. ```js
  336. const onIgnore = ({ glob, regex, input, output }) => {
  337. console.log({ glob, regex, input, output });
  338. };
  339. const isMatch = picomatch('*', { onIgnore, ignore: 'f*' });
  340. isMatch('foo');
  341. isMatch('bar');
  342. isMatch('baz');
  343. ```
  344. #### options.onResult
  345. ```js
  346. const onResult = ({ glob, regex, input, output }) => {
  347. console.log({ glob, regex, input, output });
  348. };
  349. const isMatch = picomatch('*', { onResult, ignore: 'f*' });
  350. isMatch('foo');
  351. isMatch('bar');
  352. isMatch('baz');
  353. ```
  354. <br>
  355. <br>
  356. ## Globbing features
  357. * [Basic globbing](#basic-globbing) (Wildcard matching)
  358. * [Advanced globbing](#advanced-globbing) (extglobs, posix brackets, brace matching)
  359. ### Basic globbing
  360. | **Character** | **Description** |
  361. | --- | --- |
  362. | `*` | 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`. |
  363. | `**` | Matches any character zero or more times, including path separators. Note that `**` will only match path separators (`/`, and `\\` on Windows) 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`. |
  364. | `?` | Matches any character excluding path separators one time. Does _not match_ path separators or leading dots. |
  365. | `[abc]` | Matches any characters inside the brackets. For example, `[abc]` would match the characters `a`, `b` or `c`, and nothing else. |
  366. #### Matching behavior vs. Bash
  367. 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:
  368. * Bash will match `foo/bar/baz` with `*`. Picomatch only matches nested directories with `**`.
  369. * 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`.
  370. <br>
  371. ### Advanced globbing
  372. * [extglobs](#extglobs)
  373. * [POSIX brackets](#posix-brackets)
  374. * [Braces](#brace-expansion)
  375. #### Extglobs
  376. | **Pattern** | **Description** |
  377. | --- | --- |
  378. | `@(pattern)` | Match _only one_ consecutive occurrence of `pattern` |
  379. | `*(pattern)` | Match _zero or more_ consecutive occurrences of `pattern` |
  380. | `+(pattern)` | Match _one or more_ consecutive occurrences of `pattern` |
  381. | `?(pattern)` | Match _zero or **one**_ consecutive occurrences of `pattern` |
  382. | `!(pattern)` | Match _anything but_ `pattern` |
  383. **Examples**
  384. ```js
  385. const pm = require('picomatch');
  386. // *(pattern) matches ZERO or more of "pattern"
  387. console.log(pm.isMatch('a', 'a*(z)')); // true
  388. console.log(pm.isMatch('az', 'a*(z)')); // true
  389. console.log(pm.isMatch('azzz', 'a*(z)')); // true
  390. // +(pattern) matches ONE or more of "pattern"
  391. console.log(pm.isMatch('a', 'a*(z)')); // true
  392. console.log(pm.isMatch('az', 'a*(z)')); // true
  393. console.log(pm.isMatch('azzz', 'a*(z)')); // true
  394. // supports multiple extglobs
  395. console.log(pm.isMatch('foo.bar', '!(foo).!(bar)')); // false
  396. // supports nested extglobs
  397. console.log(pm.isMatch('foo.bar', '!(!(foo)).!(!(bar))')); // true
  398. ```
  399. #### POSIX brackets
  400. POSIX classes are disabled by default. Enable this feature by setting the `posix` option to true.
  401. **Enable POSIX bracket support**
  402. ```js
  403. console.log(pm.makeRe('[[:word:]]+', { posix: true }));
  404. //=> /^(?:(?=.)[A-Za-z0-9_]+\/?)$/
  405. ```
  406. **Supported POSIX classes**
  407. The following named POSIX bracket expressions are supported:
  408. * `[:alnum:]` - Alphanumeric characters, equ `[a-zA-Z0-9]`
  409. * `[:alpha:]` - Alphabetical characters, equivalent to `[a-zA-Z]`.
  410. * `[:ascii:]` - ASCII characters, equivalent to `[\\x00-\\x7F]`.
  411. * `[:blank:]` - Space and tab characters, equivalent to `[ \\t]`.
  412. * `[:cntrl:]` - Control characters, equivalent to `[\\x00-\\x1F\\x7F]`.
  413. * `[:digit:]` - Numerical digits, equivalent to `[0-9]`.
  414. * `[:graph:]` - Graph characters, equivalent to `[\\x21-\\x7E]`.
  415. * `[:lower:]` - Lowercase letters, equivalent to `[a-z]`.
  416. * `[:print:]` - Print characters, equivalent to `[\\x20-\\x7E ]`.
  417. * `[:punct:]` - Punctuation and symbols, equivalent to `[\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~]`.
  418. * `[:space:]` - Extended space characters, equivalent to `[ \\t\\r\\n\\v\\f]`.
  419. * `[:upper:]` - Uppercase letters, equivalent to `[A-Z]`.
  420. * `[:word:]` - Word characters (letters, numbers and underscores), equivalent to `[A-Za-z0-9_]`.
  421. * `[:xdigit:]` - Hexadecimal digits, equivalent to `[A-Fa-f0-9]`.
  422. See the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html) for more information.
  423. ### Braces
  424. Picomatch does not do brace expansion. For [brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html) and advanced matching with braces, use [micromatch](https://github.com/micromatch/micromatch) instead. Picomatch has very basic support for braces.
  425. ### Matching special characters as literals
  426. 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:
  427. **Special Characters**
  428. Some characters that are used for matching in regular expressions are also regarded as valid file path characters on some platforms.
  429. To match any of the following characters as literals: `$^*+?()[]
  430. Examples:
  431. ```js
  432. console.log(pm.makeRe('foo/bar \\(1\\)'));
  433. console.log(pm.makeRe('foo/bar \\(1\\)'));
  434. ```
  435. <br>
  436. <br>
  437. ## Library Comparisons
  438. 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).
  439. | **Feature** | `minimatch` | `micromatch` | `picomatch` | `nanomatch` | `extglob` | `braces` | `expand-brackets` |
  440. | --- | --- | --- | --- | --- | --- | --- | --- |
  441. | Wildcard matching (`*?+`) | ✔ | ✔ | ✔ | ✔ | - | - | - |
  442. | Advancing globbing | ✔ | ✔ | ✔ | - | - | - | - |
  443. | Brace _matching_ | ✔ | ✔ | ✔ | - | - | ✔ | - |
  444. | Brace _expansion_ | ✔ | ✔ | - | - | - | ✔ | - |
  445. | Extglobs | partial | ✔ | ✔ | - | ✔ | - | - |
  446. | Posix brackets | - | ✔ | ✔ | - | - | - | ✔ |
  447. | Regular expression syntax | - | ✔ | ✔ | ✔ | ✔ | - | ✔ |
  448. | File system operations | - | - | - | - | - | - | - |
  449. <br>
  450. <br>
  451. ## Benchmarks
  452. Performance comparison of picomatch and minimatch.
  453. ```
  454. # .makeRe star
  455. picomatch x 1,993,050 ops/sec ±0.51% (91 runs sampled)
  456. minimatch x 627,206 ops/sec ±1.96% (87 runs sampled))
  457. # .makeRe star; dot=true
  458. picomatch x 1,436,640 ops/sec ±0.62% (91 runs sampled)
  459. minimatch x 525,876 ops/sec ±0.60% (88 runs sampled)
  460. # .makeRe globstar
  461. picomatch x 1,592,742 ops/sec ±0.42% (90 runs sampled)
  462. minimatch x 962,043 ops/sec ±1.76% (91 runs sampled)d)
  463. # .makeRe globstars
  464. picomatch x 1,615,199 ops/sec ±0.35% (94 runs sampled)
  465. minimatch x 477,179 ops/sec ±1.33% (91 runs sampled)
  466. # .makeRe with leading star
  467. picomatch x 1,220,856 ops/sec ±0.40% (92 runs sampled)
  468. minimatch x 453,564 ops/sec ±1.43% (94 runs sampled)
  469. # .makeRe - basic braces
  470. picomatch x 392,067 ops/sec ±0.70% (90 runs sampled)
  471. minimatch x 99,532 ops/sec ±2.03% (87 runs sampled))
  472. ```
  473. <br>
  474. <br>
  475. ## Philosophies
  476. The goal of this library is to be blazing fast, without compromising on accuracy.
  477. **Accuracy**
  478. 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})`.
  479. 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.
  480. **Performance**
  481. 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.
  482. <br>
  483. <br>
  484. ## About
  485. <details>
  486. <summary><strong>Contributing</strong></summary>
  487. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  488. Please read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.
  489. </details>
  490. <details>
  491. <summary><strong>Running Tests</strong></summary>
  492. 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:
  493. ```sh
  494. npm install && npm test
  495. ```
  496. </details>
  497. <details>
  498. <summary><strong>Building docs</strong></summary>
  499. _(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.)_
  500. To generate the readme, run the following command:
  501. ```sh
  502. npm install -g verbose/verb#dev verb-generate-readme && verb
  503. ```
  504. </details>
  505. ### Author
  506. **Jon Schlinkert**
  507. * [GitHub Profile](https://github.com/jonschlinkert)
  508. * [Twitter Profile](https://twitter.com/jonschlinkert)
  509. * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
  510. ### License
  511. Copyright © 2017-present, [Jon Schlinkert](https://github.com/jonschlinkert).
  512. Released under the [MIT License](LICENSE).