View Source PathGlob (PathGlob v0.2.0)
Implements glob matching using the same semantics as Path.wildcard/2
, but
without any filesystem interaction.
Link to this section Summary
Link to this section Functions
Compiles glob
to a Regex
.
Raises ArgumentError
if glob
is invalid.
examples
Examples
iex> PathGlob.compile("{lib,test}/*")
~r{^(lib|test)/([^\./]|(?<=[^/])\.)*$}
iex> PathGlob.compile("{lib,test}/path_*.ex", match_dot: true)
~r{^(lib|test)/path_[^/]*\.ex$}
Returns whether or not path
matches the glob
.
The glob is first parsed and compiled as a regular expression. If you're
using the same glob multiple times in performance-critical code, consider
using compile/1
and caching the result.
examples
Examples
iex> PathGlob.match?("lib/path_glob.ex", "{lib,test}/path_*.ex")
true
iex> PathGlob.match?("lib/.formatter.exs", "lib/*", match_dot: true)
true