Philiprehberger.GlobMatcher 0.2.0

dotnet add package Philiprehberger.GlobMatcher --version 0.2.0
                    
NuGet\Install-Package Philiprehberger.GlobMatcher -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Philiprehberger.GlobMatcher" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.GlobMatcher" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Philiprehberger.GlobMatcher" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Philiprehberger.GlobMatcher --version 0.2.0
                    
#r "nuget: Philiprehberger.GlobMatcher, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Philiprehberger.GlobMatcher@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Philiprehberger.GlobMatcher&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Philiprehberger.GlobMatcher&version=0.2.0
                    
Install as a Cake Tool

Philiprehberger.GlobMatcher

CI NuGet Last updated

Match file paths against glob patterns — supports *, **, ?, character classes, brace expansion, and negation.

Installation

dotnet add package Philiprehberger.GlobMatcher

Usage

using Philiprehberger.GlobMatcher;

var matched = Glob.IsMatch("src/**/*.cs", "src/Models/User.cs");
// true

Match Single Path

using Philiprehberger.GlobMatcher;

Glob.IsMatch("*.txt", "readme.txt");       // true
Glob.IsMatch("src/*.cs", "src/Program.cs"); // true
Glob.IsMatch("**/*.json", "a/b/c.json");   // true
Glob.IsMatch("file?.log", "file1.log");     // true
Glob.IsMatch("[abc].txt", "b.txt");         // true

Filter Collections

using Philiprehberger.GlobMatcher;

var files = new[] { "app.cs", "app.js", "lib.cs", "readme.md" };

var csFiles = Glob.Match("*.cs", files);
// ["app.cs", "lib.cs"]

var filtered = Glob.Filter("*.cs", files);
// ["app.cs", "lib.cs"]  (alias for Match)

Compiled Patterns

Pre-compile a pattern for efficient reuse across multiple match operations:

using Philiprehberger.GlobMatcher;

var compiled = Glob.Compile("src/**/*.cs");

compiled.IsMatch("src/Models/User.cs"); // true
compiled.IsMatch("test/foo.cs");        // false

var files = new[] { "src/App.cs", "src/readme.md", "src/Lib.cs" };
var csFiles = compiled.Filter(files);
// ["src/App.cs", "src/Lib.cs"]

With options:

var compiled = Glob.Compile("*.CS", new GlobOptions(CaseSensitive: false));
compiled.IsMatch("App.cs"); // true

Negation Patterns

using Philiprehberger.GlobMatcher;

Glob.IsMatch("!*.log", "data.csv");  // true
Glob.IsMatch("!*.log", "error.log"); // false

API

Glob

Method Description
IsMatch(string pattern, string path) Test if a path matches a glob pattern
IsMatch(string pattern, string path, GlobOptions options) Test with custom options
Match(string pattern, IEnumerable<string> paths) Return all matching paths
Filter(string pattern, IEnumerable<string> paths) Alias for Match
Compile(string pattern, GlobOptions? options) Pre-compile a pattern for reuse

CompiledGlob

Method Description
IsMatch(string path) Test if a path matches the compiled pattern
Filter(IEnumerable<string> paths) Return all matching paths
Pattern The original pattern string

GlobOptions

Property Type Default Description
CaseSensitive bool true Whether matching is case-sensitive
PathSeparator char '/' Path separator character

Development

dotnet build src/Philiprehberger.GlobMatcher.csproj --configuration Release

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 116 4/5/2026
0.1.1 114 4/1/2026
0.1.0 110 3/21/2026