Wild

Build Status Hex.pm version

Wild is a wildcard matching library that mimics unix-style pattern matching functionality in Elixir; it does not interact with the file system. It works on all binary input and defaults to working with codepoint representations of binaries, but other modes are also available.

Installation

Add the :wild dependency to your mix.exs file:

def deps do
  [
    {:wild, "~> 1.0.0-rc.4"}
  ]
end

Example Usage

# Simple match
iex> Wild.match?("foobar", "foo*")
true

# Simple non-match
iex> Wild.match?("foobar", "bar*")
false

# Classes are supported
iex> Wild.match?("foobar", "fo[a-z]bar")
true

# Non-printable binaries can be matched in byte mode
iex> Wild.match?(<<16, 196, 130, 4>>, "????", mode: :byte)
true

# Check validity of pattern
iex> Wild.valid_pattern?("fo[a-z]b?r")
true