https://github.com/ackara/globn
A netstandard file pattern matching library that outperforms regex.
https://github.com/ackara/globn
file glob matching minimatch netstandard pattern
Last synced: 2 months ago
JSON representation
A netstandard file pattern matching library that outperforms regex.
- Host: GitHub
- URL: https://github.com/ackara/globn
- Owner: Ackara
- License: mit
- Created: 2018-01-08T14:15:06.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-02T21:22:29.000Z (over 6 years ago)
- Last Synced: 2025-01-25T08:09:33.962Z (over 1 year ago)
- Topics: file, glob, matching, minimatch, netstandard, pattern
- Language: HTML
- Homepage:
- Size: 376 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# GlobN
[](https://www.nuget.org/packages/Acklann.GlobN/)
**GlobN** is a fast file pattern matching library for that outperforms Regex ([see benchmarks](tests/GlobN.Benchmark/BenchmarkDotNet.Artifacts/results/vbench.html)).
## Usage
**GlobN** is available at [nuget](https://www.nuget.org/packages/Acklann.GlobN). `PM> Install-Package Acklann.GlobN`
```csharp
bool success = Glob.IsMatch("index.html", "index.*");
/* returns: true */
Glob pattern = "**/*.js";
IEnumerable 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 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.**