Skip to content

ileitch/swift-filename-matcher

Repository files navigation

swift-filename-matcher

A Swift port of Python's fnmatch module with optional support for Bash 'globstar' behavior (**).

Installation

Swift Package Manager

.package(url: "https://github.com/ileitch/swift-filename-matcher.git", from: "0.0.0")
.product(name: "FilenameMatcher", package: "swift-filename-matcher")

Bazel

bazel_dep(name = "swift-filename-matcher", version = "<version>")

Usage

let matcher = FilenameMatcher(
    pattern: "**/*.swift",
    options: [.globstar]
)
matcher.match(filename: "path/to/File.swift") // true

To obtain the regex for a given pattern:

FilenameMatcher.translate("**/File.swift") // (?s:(.*/)?File\.swift)\Z

Options

See FilenameMatcherOptions for the options that can be passed to FilenameMatcher. Note that 'globstar' support is enabled by default.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published