Skip to content

Latest commit

 

History

History
45 lines (34 loc) · 1008 Bytes

README.md

File metadata and controls

45 lines (34 loc) · 1008 Bytes

Wild

Build Status Hex.pm version

Wild is a wildcard matching library that implements unix-style blob pattern matching functionality for Elixir binaries (without actually interacting with the filesystem itself). 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.1"}
  ]
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