Get Started
| Product | Versions |
|---|---|
| .NET |
README
Meziantou.Framework.Globbing
Supported glob features
*matches any number of characters including none?matches a single character[abc]matches one character given in the bracket[!abc]matches any character not in the brackets[a-z]matches one character from the range given in the bracket[!a-z]matches one character not in the range given in the bracket{abc,123}matches one of the literals**matches zero or more directories
Dialects
| Dialect | Follows | Notes |
|---|---|---|
Standard |
the syntax above | Wildcards skip names starting with a dot unless GlobOptions.MatchLeadingDot is set |
Git |
gitignore(5) and git's wildmatch | [^a], [[:alpha:]], \ escapes in brackets; {} are literal; use GlobCollection.ParseGitIgnore for a whole .gitignore file |
MSBuild |
MSBuild item specs | / and \ are separators, %XX escapes, *.* matches every file, a leading .. is kept |
Posix |
fnmatch(3) without flags |
Matches a plain string: * and ? match /; [[:alpha:]], [[=a=]], [[.-.]], [^a] |
PosixPath |
fnmatch(3) with FNM_PATHNAME |
Same syntax as Posix, but a / is only matched by a / |
The Git, MSBuild, Posix and PosixPath dialects are tested against corpora produced by git, MSBuild and
fnmatch. Characters are compared as UTF-16 code units, whereas git compares the bytes of their UTF-8 encoding.
Usage
Install the NuGet package Meziantou.Framework.Globbing (NuGet)
dotnet package add Meziantou.Framework.Globbing
IsMatchtests whether a file matches the glob patternGlob glob = Glob.Parse("src/**/*.txt", GlobDialect.Standard, GlobOptions.IgnoreCase); glob.IsMatch("src/abc.txt");Enumerate files that match a glob pattern
// Enumerate files that match the glob in the folder rootDirectory Glob glob = Glob.Parse("src/**/*.txt", GlobDialect.Standard); foreach(var file in glob.EnumerateFiles("rootDirectory")) { Console.WriteLine(file); }
Addition resources
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.