All Projects → terkelg → globrex

terkelg / globrex

Licence: MIT license
Glob to regular expression with support for extended globs.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to globrex

extglob
Extended globs. Add (almost) the expressive power of regular expressions to glob patterns.
Stars: ✭ 25 (-51.92%)
Mutual labels:  pattern, regex, glob, regular-expression, globbing
Micromatch
Contributing Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Please read the contributing guide for advice on opening issues, pull requests, and coding standards.
Stars: ✭ 1,979 (+3705.77%)
Mutual labels:  regex, glob, regular-expression, wildcard, globbing
expand-brackets
Expand POSIX bracket expressions (character classes) in glob patterns.
Stars: ✭ 26 (-50%)
Mutual labels:  regex, regexp, glob, regular-expression, globbing
Globbing
Introduction to "globbing" or glob matching, a programming concept that allows "filepath expansion" and matching using wildcards.
Stars: ✭ 86 (+65.38%)
Mutual labels:  pattern, regex, glob, regular-expression
regXwild
⏱ Superfast ^Advanced wildcards++? | Unique algorithms that was implemented on native unmanaged C++ but easily accessible in .NET via Conari (with caching of 0x29 opcodes +optimizations) etc.
Stars: ✭ 20 (-61.54%)
Mutual labels:  regex, regexp, glob, wildcard
Picomatch
Blazing fast and accurate glob matcher written JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.
Stars: ✭ 393 (+655.77%)
Mutual labels:  regex, regexp, glob, regular-expression
Commonregex
🍫 A collection of common regular expressions for Go
Stars: ✭ 733 (+1309.62%)
Mutual labels:  pattern, regex, regexp, regular-expression
Grex
A command-line tool and library for generating regular expressions from user-provided test cases
Stars: ✭ 4,847 (+9221.15%)
Mutual labels:  regex, regexp, regular-expression
cregex
A small implementation of regular expression matching engine in C
Stars: ✭ 72 (+38.46%)
Mutual labels:  regex, regexp, regular-expression
regexp-expand
Show the ELisp regular expression at point in rx form.
Stars: ✭ 18 (-65.38%)
Mutual labels:  regex, regexp, regular-expression
Regexpu
A source code transpiler that enables the use of ES2015 Unicode regular expressions in ES5.
Stars: ✭ 201 (+286.54%)
Mutual labels:  regex, regexp, regular-expression
Regex For Regular Folk
🔍💪 Regular Expressions for Regular Folk — A visual, example-based introduction to RegEx [BETA]
Stars: ✭ 242 (+365.38%)
Mutual labels:  regex, regexp, regular-expression
dir-glob
Convert directories to glob compatible strings
Stars: ✭ 41 (-21.15%)
Mutual labels:  pattern, glob, globbing
Regex Dos
👮 👊 RegEx Denial of Service (ReDos) Scanner
Stars: ✭ 143 (+175%)
Mutual labels:  regex, regexp, regular-expression
Orchestra
One language to be RegExp's Successor. Visually readable and rich, technically safe and extended, naturally scalable, advanced, and optimized
Stars: ✭ 103 (+98.08%)
Mutual labels:  regex, regexp, regular-expression
Hyperscan Java
Match tens of thousands of regular expressions within milliseconds - Java bindings for Intel's hyperscan 5
Stars: ✭ 66 (+26.92%)
Mutual labels:  regex, regexp, regular-expression
Nanomatch
Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but without support for extended globs (extglobs), posix brackets or braces, and with complete Bash 4.3 wildcard support: ("*", "**", and "?").
Stars: ✭ 79 (+51.92%)
Mutual labels:  pattern, glob, regular-expression
matched
Glob matching with support for multiple patterns and negation. Use `~` in cwd to find files in user home, or `@` for global npm modules.
Stars: ✭ 25 (-51.92%)
Mutual labels:  pattern, glob, wildcard
Is Glob
If you use globs, this will make your code faster. Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience. 55+ million downloads.
Stars: ✭ 63 (+21.15%)
Mutual labels:  regex, regexp, glob
Emoji Regex
A regular expression to match all Emoji-only symbols as per the Unicode Standard.
Stars: ✭ 1,134 (+2080.77%)
Mutual labels:  regex, regexp, regular-expression
globrex

globrex

Simple but powerful glob to regular expression compiler.

Install

npm install globrex --save

Core Features

  • 💪 extended globbing: transform advance ExtGlob features
  • 📦 simple: no dependencies
  • 🛣️ paths: split paths into multiple RegExp segments

Usage

const globrex = require('globrex');

const result = globrex('p*uck')
// => { regex: /^p.*uck$/, string: '^p.*uck$', segments: [ /^p.*uck$/ ] }

result.regex.test('pluck'); // true

API

globrex(glob, options)

Type: function
Returns: Object

Transform globs into regular expressions. Returns object with the following properties:

regex

Type: RegExp

JavaScript RegExp instance.

Note: Read more about how to use RegExp on MDN.

path

This property only exists if the option filepath is true.

Note: filepath is false by default

path.segments

Type: Array

Array of RegExp instances seperated by /. This can be usable when working with file paths or urls.

Example array could be:

[ /^foo$/, /^bar$/, /^([^\/]*)$/, '^baz\\.(md|js|txt)$' ]

path.regex

Type: RegExp

JavaScript RegExp instance build for testign against paths. The regex have different path seperators depending on host OS.

glob

Type: String

Glob string to transform.

options.extended

Type: Boolean
Default: false

Enable all advanced features from extglob.

Matching so called "extended" globs pattern like single character matching, matching ranges of characters, group matching, etc.

Note: Interprets [a-d] as [abcd]. To match a literal -, include it as first or last character.

options.globstar

Type: Boolean
Default: false

When globstar is false globs like '/foo/*' are transformed to the following '^\/foo\/.*$' which will match any string beginning with '/foo/'.

When the globstar option is true, the same '/foo/*' glob is transformed to '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' that does not have a '/' to the right of it. '/foo/*' will match: '/foo/bar', '/foo/bar.txt' but not '/foo/bar/baz' or '/foo/bar/baz.txt'.

Note: When globstar is true, '/foo/**' is equivelant to '/foo/*' when globstar is false.

options.strict

Type: Boolean
Default: false

Be forgiving about mutiple slashes, like /// and make everything after the first / optional. This is how bash glob works.

options.flags

Type: String
Default: ''

RegExp flags (e.g. 'i' ) to pass to the RegExp constructor.

options.filepath

Type: Boolean
Default: false

Parse input strings as it was a file path for special path related features. This feature only makes sense if the input is a POSIX path like /foo/bar/hello.js or URLs.

When true the returned object will have an additional path object.

  • segment: Array containing a RegExp object for each path segment.
  • regex: OS specific file path RegExp. Path seperator used is based on the operating system.
  • globstar: Regex string used to test for globstars.

Note: Please only use forward-slashes in file path glob expressions Though windows uses either / or \ as its path separator, only / characters are used by this glob implementation. You must use forward-slashes only in glob expressions. Back-slashes will always be interpreted as escape characters, not path separators.

References

Learn more about advanced globbing here

License

MIT © Terkel Gjervig

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].