fe339a13132dce9d71e547835e1b133180757f7d48f22bcd886ff95ecec5cbd99ef52c75b685242ee32145f198ab410ffa79dc2b0561a8ffcefe25324f435c 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # extglob [![NPM version](https://badge.fury.io/js/extglob.svg)](http://badge.fury.io/js/extglob) [![Build Status](https://travis-ci.org/jonschlinkert/extglob.svg)](https://travis-ci.org/jonschlinkert/extglob)
  2. > Convert extended globs to regex-compatible strings. Add (almost) the expressive power of regular expressions to glob patterns.
  3. Install with [npm](https://www.npmjs.com/)
  4. ```sh
  5. $ npm i extglob --save
  6. ```
  7. Used by [micromatch](https://github.com/jonschlinkert/micromatch).
  8. **Features**
  9. * Convert an extglob string to a regex-compatible string. **Only converts extglobs**, to handle full globs use [micromatch](https://github.com/jonschlinkert/micromatch).
  10. * Pass `{regex: true}` to return a regex
  11. * Handles nested patterns
  12. * More complete (and correct) support than [minimatch](https://github.com/isaacs/minimatch)
  13. ## Usage
  14. ```js
  15. var extglob = require('extglob');
  16. extglob('?(z)');
  17. //=> '(?:z)?'
  18. extglob('*(z)');
  19. //=> '(?:z)*'
  20. extglob('+(z)');
  21. //=> '(?:z)+'
  22. extglob('@(z)');
  23. //=> '(?:z)'
  24. extglob('!(z)');
  25. //=> '(?!^(?:(?!z)[^/]*?)).*$'
  26. ```
  27. **Optionally return regex**
  28. ```js
  29. extglob('!(z)', {regex: true});
  30. //=> /(?!^(?:(?!z)[^/]*?)).*$/
  31. ```
  32. ## Extglob patterns
  33. To learn more about how extglobs work, see the docs for [Bash pattern matching](https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html):
  34. * `?(pattern)`: Match zero or one occurrence of the given pattern.
  35. * `*(pattern)`: Match zero or more occurrences of the given pattern.
  36. * `+(pattern)`: Match one or more occurrences of the given pattern.
  37. * `@(pattern)`: Match one of the given pattern.
  38. * `!(pattern)`: Match anything except one of the given pattern.
  39. ## Related
  40. * [braces](https://github.com/jonschlinkert/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://github.com/jonschlinkert/braces)
  41. * [expand-brackets](https://github.com/jonschlinkert/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns.
  42. * [expand-range](https://github.com/jonschlinkert/expand-range): Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See… [more](https://github.com/jonschlinkert/expand-range)
  43. * [fill-range](https://github.com/jonschlinkert/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://github.com/jonschlinkert/fill-range)
  44. * [micromatch](https://github.com/jonschlinkert/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… [more](https://github.com/jonschlinkert/micromatch)
  45. ## Run tests
  46. Install dev dependencies:
  47. ```sh
  48. $ npm i -d && npm test
  49. ```
  50. ## Contributing
  51. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/extglob/issues/new)
  52. ## Author
  53. **Jon Schlinkert**
  54. + [github/jonschlinkert](https://github.com/jonschlinkert)
  55. + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  56. ## License
  57. Copyright © 2015 Jon Schlinkert
  58. Released under the MIT license.
  59. ***
  60. _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 01, 2015._