ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - gniquil/ex_minimatch
Contribute to gniquil/ex_minimatch development by creating an account on GitHub.
Visit Site

GitHub - gniquil/ex_minimatch

GitHub - gniquil/ex_minimatch

ExMinimatch

Globbing paths without walking the tree! Elixir and Erlang provide wildcard functions in the stdlib. But these will walk the directory tree. If you simply want to test whether a file path matches a glob, ExMinimatch is for you.

Quick examples:

iex> import ExMinimatch
nil

iex> match("**/*{1..2}{a,b}.{png,jpg}", "asdf/pic2a.jpg")
true

iex> match("*.+(bar|foo)", "bar.foo")
true

iex> ["me.jpg", "images/me.png", "images/you.svg"] |> filter("**/*.{png,jpg}")
["me.jpg", "images/me.png"]

Compiled forms below allows us to cache the %ExMinimatcher{} struct when used against large number of files repeated.

iex> compile("**/*{1..2}{a,b}.{png,jpg}") |> match("asdf/pic2a.jpg")
true

iex> ["me.jpg", "images/me.png", "images/you.svg"] |> filter(compile("**/*.{png,jpg}"))
["me.jpg", "images/me.png"]

ExMinimatch is a port of the minimatch javascript project. It is a close port but not exactly the same. See "Comparison to minimatch.js" section below.

Glob Patterns

Supports these glob features:

See:

  • man sh
  • man bash
  • man 3 fnmatch
  • man 5 gitignore

Options

compile, match, and filter all have forms that take an options argument (as a map %{}). The following are the explanations. By default, all fo these are false.

log

Possible values are :info, and :debug. If set, will dump information into repl. :debug dumps more.

nobrace

Do not expand {a,b} and {1..3} brace sets.

noglobstar

Disable ** matching against multiple folder names.

dot

Allow patterns to match filenames starting with a period, even if the pattern does not explicitly have a period in that spot.

Note that by default, a/**/b will not match a/.d/b, unless dot is set, e.g. match("a/**/b", "a/.d/b", %{dot: true})

noext

Disable "extglob" style patterns like +(a|b).

nocase

Perform a case-insensitive match.

match_base

If set, then patterns without slashes will be matched against the basename of the path if it contains slashes. For example, a?b would match the path /xyz/123/acb, but not /xyz/acb/123.

nocomment

Suppress the behavior of treating # at the start of a pattern as a comment.

nonegate

Suppress the behavior of treating leading ! character as negation.

Comparison to minimatch.js

minimatch.js converts a glob into a list of regular expressions. However, when it comes to matching, one can choose to use minimatch.match or use the complete regular expression generated by minimatch.makeRe to test it against a file pattern. Unfortunately, the 2 approaches are inconsistent. Notably the full regular expression based approach has a few important pieces missing. Therefore, here we implement the first approach. For detail, take a look at ExMinimatcher.Matcher.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory