#pattern #pattern-match #regex

goglob

Shell pattern matching similar to golang's path.Match

1 unstable release

0.2.0 Apr 15, 2022

#1352 in Filesystem


Used in 2 crates

BSD-3-Clause

40KB
786 lines

goglob

Shell pattern matching similar to golang's path.Match.

The pattern syntax is:

pattern:
    { term }
term:
    '*'         matches any sequence of non-/ characters
    '?'         matches any single non-/ character
    '[' [ '^' ] { character-range } ']'
                character class (must be non-empty)
    c           matches character c (c != '*', '?', '\\', '[')
    '\\' c      matches character c

character-range:
    c           matches character c (c != '\\', '-', ']')
    '\\' c      matches character c
    lo '-' hi   matches character c for lo <= c <= hi

Match requires pattern to match all of name, not just a substring.

Use GlobPattern::new(pattern) to construct a new instance.

Features

  • proc-macro: allows using the glob!("<PATTERN>") procedural macro (see glob!()).
  • serde: enables serde deserialization of string patterns.

License

BSD-3-Clause.

Based in Go 1.18's path.Match (available under the BSD-3-Clause license) which contains the following comment:

// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

Dependencies

~0–265KB