# 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)
> Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Table of Contents
<details>
<summary><strong>Details</strong></summary>
- [Install](#install)
- [Quickstart](#quickstart)
- [Why use micromatch?](#why-use-micromatch)
* [Matching features](#matching-features)
- [Switching to micromatch](#switching-to-micromatch)
* [From minimatch](#from-minimatch)
* [From multimatch](#from-multimatch)
- [API](#api)
- [Options](#options)
* [options.basename](#optionsbasename)
* [options.bash](#optionsbash)
* [options.cache](#optionscache)
* [options.dot](#optionsdot)
* [options.failglob](#optionsfailglob)
* [options.ignore](#optionsignore)
* [options.matchBase](#optionsmatchbase)
* [options.nobrace](#optionsnobrace)
* [options.nocase](#optionsnocase)
* [options.nodupes](#optionsnodupes)
* [options.noext](#optionsnoext)
* [options.nonegate](#optionsnonegate)
* [options.noglobstar](#optionsnoglobstar)
* [options.nonull](#optionsnonull)
* [options.nullglob](#optionsnullglob)
* [options.snapdragon](#optionssnapdragon)
* [options.sourcemap](#optionssourcemap)
* [options.unescape](#optionsunescape)
* [options.unixify](#optionsunixify)
- [Extended globbing](#extended-globbing)
* [extglobs](#extglobs)
* [braces](#braces)
* [regex character classes](#regex-character-classes)
* [regex groups](#regex-groups)
* [POSIX bracket expressions](#posix-bracket-expressions)
- [Notes](#notes)
* [Bash 4.3 parity](#bash-43-parity)
* [Backslashes](#backslashes)
- [Contributing](#contributing)
- [Benchmarks](#benchmarks)
* [Running benchmarks](#running-benchmarks)
* [Latest results](#latest-results)
- [About](#about)
</details>
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save micromatch
```
## Quickstart
```js
var mm = require('micromatch');
mm(list, patterns[, options]);
```
The [main export](#micromatch) takes a list of strings and one or more glob patterns:
```js
console.log(mm(['foo', 'bar', 'qux'], ['f*', 'b*']));
//=> ['foo', 'bar']
```
Use [.isMatch()](#ismatch) to get true/false:
```js
console.log(mm.isMatch('foo', 'f*'));
//=> true
```
[Switching](#switching-to-micromatch) from minimatch and multimatch is easy!
## Why use micromatch?
> micromatch is a [drop-in replacement](#switching-to-micromatch) for minimatch and multimatch
* Supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch)
* 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.
* More consistently accurate matching [than minimatch](https://github.com/yarnpkg/yarn/pull/3339), with more than 36,000 [test assertions](./test) to prove it.
* 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.
* [Faster matching](#benchmarks), from a combination of optimized glob patterns, faster algorithms, and regex caching.
* [Micromatch is safer](https://github.com/micromatch/braces#braces-is-safe), and is not subject to DoS with brace patterns, like minimatch and multimatch.
* More reliable windows support than minimatch and multimatch.
### Matching features
* Support for multiple glob patterns (no need for wrappers like multimatch)
* Wildcards (`**`, `*.js`)
* Negation (`'!a/*.js'`, `'*!(b).js']`)
* [extglobs](https://github.com/micromatch/extglob) (`+(x|y)`, `!(a|b)`)
* [POSIX character classes](https://github.com/micromatch/expand-brackets) (`[[:alpha:][:digit:]]`)
* [brace expansion](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`)
* regex character classes (`foo-[1-5].js`)
* regex logical "or" (`foo/(abc|xyz).js`)
You can mix and match these features to create whatever patterns you need!
## Switching to micromatch
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.
### From minimatch
Use [mm.isMatch()](#ismatch) instead of `minimatch()`:
```js
mm.isMatch('foo', 'b*');
//=> false
```
Use [mm.match()](#match) instead of `minimatch.match()`:
```js
mm.match(['foo', 'bar'], 'b*');
//=> 'bar'
```
### From multimatch
Same signature:
```js
mm(['foo', 'bar', 'baz'], ['f*', '*z']);
//=> ['foo', 'baz']
```
## API
### [micromatch](index.js#L41)
The main function takes a list of strings and one or more glob patterns to use for matching.
**Params**
* `list` **{Array}**: A list of strings to match
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Array}**: Returns an array of matches
**Example**
```js
var mm = require('micromatch');
mm(list, patterns[, options]);
console.log(mm(['a.js', 'a.txt'], ['*.js']));
//=> [ 'a.js' ]
```
### [.match](index.js#L93)
Similar to the main function, but `pattern` must be a string.
**Params**
* `list` **{Array}**: Array of strings to match
* `pattern` **{String}**: Glob pattern to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Array}**: Returns an array of matches
**Example**
```js
var mm = require('micromatch');
mm.match(list, pattern[, options]);
console.log(mm.match(['a.a', 'a.aa', 'a.b', 'a.c'], '*.a'));
//=> ['a.a', 'a.aa']
```
### [.isMatch](index.js#L154)
Returns true if the specified `string` matches the given glob `pattern`.
**Params**
* `string` **{String}**: String to match
* `pattern` **{String}**: Glob pattern to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if the string matches the glob pattern.
**Example**
```js
var mm = require('micromatch');
mm.isMatch(string, pattern[, options]);
console.log(mm.isMatch('a.a', '*.a'));
//=> true
console.log(mm.isMatch('a.b', '*.a'));
//=> false
```
### [.some](index.js#L192)
Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
**Params**
* `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found.
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
* `returns` **{Boolean}**: Returns true if any patterns match `str`
**Example**
```js
var mm = require('micromatch');
mm.some(list, patterns[, options]);
console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
// true
console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
// false
```
### [.every](index.js#L228)
Returns true if every strin
不走小道
- 粉丝: 3382
- 资源: 5051
最新资源
- 日立hgp电梯mcub03主板维修原理图 日立gvf电梯mcub01主板维修原理图 日立hgp电梯evecd03变频器维修原理图 日立gvf电梯evecd01变频器维修原理图 日立hge电梯els-4
- 基于Python3的Mysql数据库操作封装类解析及其应用
- S7-200Smart PLC,MCGS触摸屏,使用中的机组程序,采用通讯方式同步控制3台变频器调速,温度采集程序
- RS422-ARINC429通讯转模块 RS422支持全双工通讯接口,通讯速率可设置,ARINC429支持发送和接收,每通道发送接收速率可单独设置,可卖板卡,也可以根据具体要求设计硬件,支持FPGA
- 无人艇(机)仿真,带gui 具体内容看图片 文字资料已遗失,主参数通过initial来生成,具体模型全部在simulink里面,可自行推导,或者加价我去推导 gui界面打开方式:在主界面输入gu
- MATLAB代码:基于多时间尺度滚动优化的多能源微网双层调度模型红旗红旗红旗火火 关键词:多能源微网 多时间尺度 滚动优化 微网双层模型 调度 红旗红旗 主要内容:代码主要
- 重庆大学 Python 考试题目解析与计算机基础知识点复习资料
- 西门子300PLC 分时产量计数程序,在地址不冲突情况下,改个启动计数条件,就可以拿来在项目上直接使用,间接寻址,程序直观明了,触摸屏有系统时间更改功能
- LNOI绝缘体上铌酸锂薄膜电光调制特性
- Apollo7.0-行为预测模块思维导图及该模块注释代码 , Apollo 7.0为Apollo最新版本,此次重点针对感知和预测算法,进行了模块升级 引入Inter-TNT行为预测模式,通过障碍物与
- 数学建模竞赛之城市交通拥堵与优化-华数杯赛题解析及应用
- 西门子UG后处理三轴后处理840D828D系统 界面简洁,没那么多字幕 无使用限制 带刀具信息 带备刀 带ij圆弧输出 输出m08冷却液 程序段m1暂停 g41半径补偿 结尾回零点 带pui 840没
- simulink 风电调频,双馈风机调频,VSG同步机控制,风电场调频,三机九节点,带有惯性控制,下垂控制 同步机为火电机组,水轮机,可实现同步机调频,火电调频,水轮机调频等 风电渗透20%,ph
- Matlab路径规划算法代码 传统A star算法源码+详细注释 可固定地图和起点终点 适合初学者入门学习使用 保证运行
- 冲床送料机程序,送料机程序,伺服送料机程序,伺服电机,程序,三菱,台达,中达一体机,送料机程序,PLC多段数据不同,可任意调节A段B段c段长度,并定长切断 程序能存储5段工件数据,使用调出非常方便
- 项目:超声波-基于Arduino的超声波距离测量(LCD1602显示) 设计;proteus 仿真(版本8.9-可提供软件安装包) 主控:Arduino UNO 外设:超声波,LCD1602 程序:
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈