A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/jonschlinkert/expand-brackets below:

micromatch/expand-brackets: Expand POSIX bracket expressions (character classes) in glob patterns.

Expand POSIX bracket expressions (character classes) in glob patterns.

Install with npm:

$ npm install --save expand-brackets

Install with yarn:

$ yarn add expand-brackets
var brackets = require('expand-brackets');
brackets(string[, options]);

Params

The main export is a function that takes the following parameters:

Example

console.log(brackets('[![:lower:]]'));
//=> '[^a-z]'

Parses the given POSIX character class pattern and returns a string that can be used for creating regular expressions for matching.

Params

Takes an array of strings and a POSIX character class pattern, and returns a new array with only the strings that matched the pattern.

Params

Example

const brackets = require('expand-brackets');
console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]'));
//=> ['a']

console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]+'));
//=> ['a', 'ab']

Returns true if the specified string matches the given brackets pattern.

Params

Example

const brackets = require('expand-brackets');

console.log(brackets.isMatch('a.a', '[[:alpha:]].[[:alpha:]]'));
//=> true
console.log(brackets.isMatch('1.2', '[[:alpha:]].[[:alpha:]]'));
//=> false

Takes a POSIX character class pattern and returns a matcher function. The returned function takes the string to match as its only argument.

Params

Example

const brackets = require('expand-brackets');
const isMatch = brackets.matcher('[[:lower:]].[[:upper:]]');

console.log(isMatch('a.a'));
//=> false
console.log(isMatch('a.A'));
//=> true

Create a regular expression from the given pattern.

Params

Example

const brackets = require('expand-brackets');
const re = brackets.makeRe('[[:alpha:]]');
console.log(re);
//=> /^(?:[a-zA-Z])$/

Parses the given POSIX character class pattern and returns an object with the compiled output and optional source map.

Params

Example

const brackets = require('expand-brackets');
console.log(brackets('[[:alpha:]]'));
// { options: { source: 'string' },
//   input: '[[:alpha:]]',
//   state: {},
//   compilers:
//    { eos: [Function],
//      noop: [Function],
//      bos: [Function],
//      not: [Function],
//      escape: [Function],
//      text: [Function],
//      posix: [Function],
//      bracket: [Function],
//      'bracket.open': [Function],
//      'bracket.inner': [Function],
//      'bracket.literal': [Function],
//      'bracket.close': [Function] },
//   output: '[a-zA-Z]',
//   ast:
//    { type: 'root',
//      errors: [],
//      nodes: [ [Object], [Object], [Object] ] },
//   parsingErrors: [] }

Generate a source map for the given pattern.

Example

var res = brackets('[:alpha:]', {sourcemap: true});

console.log(res.map);
// { version: 3,
//   sources: [ 'brackets' ],
//   names: [],
//   mappings: 'AAAA,MAAS',
//   sourcesContent: [ '[:alpha:]' ] }

The following named POSIX bracket expressions are supported:

See posix-character-classes for more details.

Not supported

Breaking changes

Breaking changes

Breaking changes

Added features

In addition to performance and matching improvements, the v0.2.0 refactor adds complete POSIX character class support, with the exception of equivalence classes and POSIX.2 collating symbols which are not relevant to node.js usage.

Added features

source map example

var brackets = require('expand-brackets');
var res = brackets('[:alpha:]');
console.log(res.map);

{ version: 3,
     sources: [ 'brackets' ],
     names: [],
     mappings: 'AAAA,MAAS',
     sourcesContent: [ '[:alpha:]' ] }

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

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:

$ npm install && npm test

Jon Schlinkert

Copyright © 2018, Jon Schlinkert. Released under the MIT License.

This file was generated by verb-generate-readme, v0.6.0, on April 30, 2018.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4