Skip to content

sogaiu/funmatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

funmatch - match glob-like pattern against string

* pattern is a simplified glob-like pattern [1]
* string is typically a filename (no directory portions)

For example:

  (funmatch "*.janet" "test.janet")
  # =>
  true

Patterns

* * - zero or more characters
* ? - one character
* [x-y] - one character in the range x <= y
* [!x-y] - one character not in the range x <= y
* [xyz] - one character in the set x, y, ..., z
* [!xyz] - one character not in the set x, y, ..., z

Implementation

The general idea is to:

1. Parse glob-like pattern into pieces (parse-pattern)
2. Create peg from parsed pieces (make-peg)
3. Apply peg/match to a string using the generated peg

Keywords: glob, fnmatch, wildmat

References

* fnmatch(3)
* glob(7)
* https://en.wikipedia.org/wiki/Glob_(programming)

---

[1] Various behavior and constructs are not supported,
    e.g. leading dots in names are not treated
    specially, sets and ranges must be expressed
    separately, no escape characters, etc.

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors

Languages