ktsu.TextFilter is a .NET library that provides methods for filtering text based on different filter types and match options. It supports glob patterns, regular expressions, and fuzzy matching to help you efficiently filter and search through collections of strings.
- Glob Pattern Matching: Filter text using glob patterns with optional, required, and excluded tokens.
- Regular Expression Matching: Filter text using regular expressions.
- Fuzzy Matching: Rank text based on how well it matches a fuzzy pattern.
- Customizable Match Options: Match by whole string, all words, or any word.
To install TextFilter, add the following NuGet packages to your project:
dotnet add package ktsu.TextFilter
You can match a single string against a pattern using the Match
method.
using ktsu.TextFilter;
string text = "Hello, World!";
string pattern = "Hello*";
bool isMatch = TextFilter.Match(text, pattern);
You can filter a collection of strings using the Filter
method.
using ktsu.TextFilter;
string[] texts = new string[] { "Hello, World!", "Goodbye, World!" };
string pattern = "Hello*";
IEnumerable<string> matches = TextFilter.Filter(texts, pattern);
You can rank a collection of strings based on how well they match a fuzzy pattern using the Rank
method.
using ktsu.TextFilter;
string[] texts = new string[] { "Hello, World!", "Goodbye, World!" };
string pattern = "Hello";
IEnumerable<string> ranked = TextFilter.Rank(texts, pattern);
Contributions are welcome! For feature requests, bug reports, or questions, please open an issue on GitHub. If you would like to contribute code, please open a pull request with your changes.
This project is licensed under the MIT License - see the LICENSE file for details.
- DotNet.Glob for glob pattern matching.
- ktsu.FuzzySearch for fuzzy matching.
For any questions or inquiries, please contact the project maintainers.