Skip to content
/ GlobN Public

A netstandard file pattern matching library that outperforms regex.

License

Notifications You must be signed in to change notification settings

Ackara/GlobN

Repository files navigation

GlobN

NuGet

GlobN is a fast file pattern matching library for that outperforms Regex (see benchmarks).

Usage

GlobN is available at nuget. PM> Install-Package Acklann.GlobN

bool success = Glob.IsMatch("index.html", "index.*");
/* returns: true */

Glob pattern = "**/*.js";
IEnumerable<string> allJsFilePaths = pattern.ResolvePaths(@"C:\app\scripts\");
/* returns: The paths of all .js files within the current directory and its sub-directories. */

Glob pattern = "../../index.html";
string fullPath = pattern.Expand();
/* returns: The full path of the specified file. */

Glob pattern = "scripts/**/auth/*.ts";
IEnumerable<string> filteredList = pattern.Filter(new string[] { ... }).
/* returns: Only the strings that match the pattern */

Supported Expressions

Pattern Description
..\ Moves the current directory up one folder. Only applicable at the beginning of the pattern.
* Match zero or more characters excluding the directory separator.
** Match zero or more directories.
? Match a single character.
! Negates the matching pattern. Only applicable at the beginning of the pattern.

NOTE: matches are case-insensitive.