Skip to main content
.NETFramework4.7.2.NETCoreApp3.1net5.0net6.0

A globbing library for .NET. Can be used to match any string or with System.IO.Enumeration.

Published
Jul 14, 2021
5y ago
Total Downloads
103.8K
103,812

Install

dotnet add package Meziantou.Framework.Globbing --version 1.0.9
ProductVersions
.NET
net5.0net6.0
Other
.NETCoreApp3.1.NETFramework4.7.2

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

Usage

Install the NuGet package Meziantou.Framework.Globbing (NuGet)

<PackageReference Include="Meziantou.Framework.Globbing" Version="1.0.4" />
  • IsMatch tests whether a file matches the glob pattern

    Glob glob = Glob.Parse("src/**/*.txt", 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", GlobOptions.None);
    foreach(var file in glob.EnumerateFiles("rootDirectory"))
    {
        Console.WriteLine(file);
    }
    

Addition resources

Changes from Previous Version

No structural changes between v1.0.8 and v1.0.9.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

No SPDX license expression is published. Review the license text and your organisation's policy before redistribution.Compatibility metadata lists 4 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.