GithubHelp home page GithubHelp logo

wildmatch's Introduction

Wildmatch NPM version Build status

Port in JS of the matching library used by Git.

Unlike other libraries like minimatch, it doesn't use regexp and use a real parser.

Usage

var wildmatch = require('wildmatch');

wildmatch('bar.foo', '*.foo'); //=> true
wildmatch('bar.foo', '*.bar'); //=> false
wildmatch('D', '[[:xdigit:]]'); //=> true

Syntax

Wildmatch support the following features:

  • ?: Match a singe character
  • *: Match any string
  • Character classes: list ([asd]), ranges ([a-z]), POSIX named classes ([[:alpha:]]), negation ([!a-f] or [^a-f])
  • Braces expansion: file.{js,json} will match file.js and file.json.
  • Sequences: {-1..1} will turn into (-1 or 0 or 1). You can also set a step size ({-5..5..5} => -5, 0, 5), use letters ({a..e..2} => a, c, e), and count backward ({Z..X} => Z, Y, X)
  • Extended glob: pattern-list is a list of patterns separated by |
    • ?(pattern-list): Matches zero or one occurrence of the given patterns
    • *(pattern-list): Matches zero or more occurrences of the given patterns
    • +(pattern-list): Matches one or more occurrences of the given patterns
    • @(pattern-list): Matches one occurrences of the given patterns
    • !(pattern-list): Matches anything except one of the given patterns

Options

You can path an options object to wildmatch as third parameter. Options include:

  • matchBase: 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.
  • case: if set to false, perform a case-insensitive match
  • pathname: if set, ?, * and character class do not match the / character
  • braces: set it to false to disable the processing of curly braces (braces expansion and sequences)
  • extglob: set it to false to disable the match of extended glob pattern lists

wildmatch's People

Contributors

vmeurisse avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.