gobwas / Glob
Licence: mit
Go glob
Stars: ✭ 670
Projects that are alternatives of or similar to Glob
dir-glob
Convert directories to glob compatible strings
Stars: ✭ 41 (-93.88%)
Mutual labels: pattern, glob
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 (-88.21%)
Mutual labels: pattern, glob
extglob
Extended globs. Add (almost) the expressive power of regular expressions to glob patterns.
Stars: ✭ 25 (-96.27%)
Mutual labels: pattern, glob
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 (-96.27%)
Mutual labels: pattern, glob
to-absolute-glob
Make a glob pattern absolute, ensuring that negative globs and patterns with trailing slashes are correctly handled.
Stars: ✭ 16 (-97.61%)
Mutual labels: pattern, glob
glob
Pure Nim library for matching file paths against Unix style glob patterns.
Stars: ✭ 58 (-91.34%)
Mutual labels: pattern, glob
Globbing
Introduction to "globbing" or glob matching, a programming concept that allows "filepath expansion" and matching using wildcards.
Stars: ✭ 86 (-87.16%)
Mutual labels: pattern, glob
globrex
Glob to regular expression with support for extended globs.
Stars: ✭ 52 (-92.24%)
Mutual labels: pattern, glob
bash-glob
Bash-powered globbing for node.js. Alternative to node-glob. Does not work on Windows 9 and lower.
Stars: ✭ 13 (-98.06%)
Mutual labels: pattern, glob
Competitive-Feature-Learning
Online feature-extraction and classification algorithm that learns representations of input patterns.
Stars: ✭ 32 (-95.22%)
Mutual labels: pattern
Anymatch
‼️ Matches strings against configurable strings, globs, regular expressions, and/or functions
Stars: ✭ 289 (-56.87%)
Mutual labels: glob
geo-pattern
Create beautiful generative geometric background images from a string ✨ TypeScript port of jasonlong/geo_pattern. Supports both Node.js and Browser.
Stars: ✭ 33 (-95.07%)
Mutual labels: pattern
Replace In File
A simple utility to quickly replace contents in one or more files
Stars: ✭ 369 (-44.93%)
Mutual labels: glob
espresso-robot-pattern-sample
Espresso Robot Pattern Sample with Spoon Integration
Stars: ✭ 37 (-94.48%)
Mutual labels: pattern
pixelscan
A Python library that provides functions to scan pixels on a grid in a variety of spatial patterns.
Stars: ✭ 23 (-96.57%)
Mutual labels: pattern
Pattern Guidance
Design pattern guide (PHP、Java、Golang implementation)
Stars: ✭ 264 (-60.6%)
Mutual labels: pattern
go
glob.Go Globbing Library.
Install
go get github.com/gobwas/glob
Example
package main
import "github.com/gobwas/glob"
func main() {
var g glob.Glob
// create simple glob
g = glob.MustCompile("*.github.com")
g.Match("api.github.com") // true
// quote meta characters and then create simple glob
g = glob.MustCompile(glob.QuoteMeta("*.github.com"))
g.Match("*.github.com") // true
// create new glob with set of delimiters as ["."]
g = glob.MustCompile("api.*.com", '.')
g.Match("api.github.com") // true
g.Match("api.gi.hub.com") // false
// create new glob with set of delimiters as ["."]
// but now with super wildcard
g = glob.MustCompile("api.**.com", '.')
g.Match("api.github.com") // true
g.Match("api.gi.hub.com") // true
// create glob with single symbol wildcard
g = glob.MustCompile("?at")
g.Match("cat") // true
g.Match("fat") // true
g.Match("at") // false
// create glob with single symbol wildcard and delimiters ['f']
g = glob.MustCompile("?at", 'f')
g.Match("cat") // true
g.Match("fat") // false
g.Match("at") // false
// create glob with character-list matchers
g = glob.MustCompile("[abc]at")
g.Match("cat") // true
g.Match("bat") // true
g.Match("fat") // false
g.Match("at") // false
// create glob with character-list matchers
g = glob.MustCompile("[!abc]at")
g.Match("cat") // false
g.Match("bat") // false
g.Match("fat") // true
g.Match("at") // false
// create glob with character-range matchers
g = glob.MustCompile("[a-c]at")
g.Match("cat") // true
g.Match("bat") // true
g.Match("fat") // false
g.Match("at") // false
// create glob with character-range matchers
g = glob.MustCompile("[!a-c]at")
g.Match("cat") // false
g.Match("bat") // false
g.Match("fat") // true
g.Match("at") // false
// create glob with pattern-alternatives list
g = glob.MustCompile("{cat,bat,[fr]at}")
g.Match("cat") // true
g.Match("bat") // true
g.Match("fat") // true
g.Match("rat") // true
g.Match("at") // false
g.Match("zat") // false
}
Performance
This library is created for compile-once patterns. This means, that compilation could take time, but strings matching is done faster, than in case when always parsing template.
If you will not use compiled glob.Glob
object, and do g := glob.MustCompile(pattern); g.Match(...)
every time, then your code will be much more slower.
Run go test -bench=.
from source root to see the benchmarks:
Pattern | Fixture | Match | Speed (ns/op) |
---|---|---|---|
[a-z][!a-x]*cat*[h][!b]*eyes* |
my cat has very bright eyes |
true |
432 |
[a-z][!a-x]*cat*[h][!b]*eyes* |
my dog has very bright eyes |
false |
199 |
https://*.google.* |
https://account.google.com |
true |
96 |
https://*.google.* |
https://google.com |
false |
66 |
{https://*.google.*,*yandex.*,*yahoo.*,*mail.ru} |
http://yahoo.com |
true |
163 |
{https://*.google.*,*yandex.*,*yahoo.*,*mail.ru} |
http://google.com |
false |
197 |
{https://*gobwas.com,http://exclude.gobwas.com} |
https://safe.gobwas.com |
true |
22 |
{https://*gobwas.com,http://exclude.gobwas.com} |
http://safe.gobwas.com |
false |
24 |
abc* |
abcdef |
true |
8.15 |
abc* |
af |
false |
5.68 |
*def |
abcdef |
true |
8.84 |
*def |
af |
false |
5.74 |
ab*ef |
abcdef |
true |
15.2 |
ab*ef |
af |
false |
10.4 |
The same things with regexp
package:
Pattern | Fixture | Match | Speed (ns/op) |
---|---|---|---|
^[a-z][^a-x].*cat.*[h][^b].*eyes.*$ |
my cat has very bright eyes |
true |
2553 |
^[a-z][^a-x].*cat.*[h][^b].*eyes.*$ |
my dog has very bright eyes |
false |
1383 |
^https:\/\/.*\.google\..*$ |
https://account.google.com |
true |
1205 |
^https:\/\/.*\.google\..*$ |
https://google.com |
false |
767 |
^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$ |
http://yahoo.com |
true |
1435 |
^(https:\/\/.*\.google\..*|.*yandex\..*|.*yahoo\..*|.*mail\.ru)$ |
http://google.com |
false |
1674 |
^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$ |
https://safe.gobwas.com |
true |
1039 |
^(https:\/\/.*gobwas\.com|http://exclude.gobwas.com)$ |
http://safe.gobwas.com |
false |
272 |
^abc.*$ |
abcdef |
true |
237 |
^abc.*$ |
af |
false |
100 |
^.*def$ |
abcdef |
true |
464 |
^.*def$ |
af |
false |
265 |
^ab.*ef$ |
abcdef |
true |
375 |
^ab.*ef$ |
af |
false |
145 |
Syntax
Syntax is inspired by standard wildcards,
except that **
is aka super-asterisk, that do not sensitive for separators.
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].