* → zero or more
report-*.txt matches report-.txt and report-summary.txt. Use stars at both ends for substring matching.
Pattern matching for .NET
Match strings and character spans with * and ?. Choose direct WildcardMatch execution or the WildcardMatchRegex string engine, with reusable matchers, case options, and explicit timeouts.
4.24× the throughput of the next-fastest tested library for the reusable direct matcher in our question-mark benchmark. Compare the measured workloads.
report-01.txtMATCHreport-aa.txtMATCHreport-1.txtNO MATCHreport-001.txtNO MATCH^report-..\.txt$Two wildcard tokensStar for a sequence, question mark for one character
Reusable patternsRetain a pattern and match multiple strings
Regex controlsCase, culture, direction, and line handling
Portable package.NET Standard 2.1 with native .NET 10 and 11 targets
Pattern language
Patterns use two operators. Every other character is literal, including dots, brackets, and regular-expression punctuation.
* → zero or morereport-*.txt matches report-.txt and report-summary.txt. Use stars at both ends for substring matching.
? → exactly onereport-??.txt requires two UTF-16 code units in that position. It matches report-01.txt.
file[1].txt matches that literal filename. This is string matching: slashes have no special path semantics.
Patterns translate to ^…$. .NET permits $ before a final newline. Wildcards exclude \n unless Singleline is set.
Choose an API
Use the same wildcard syntax through extension methods, static calls, or an instance. Direct calls avoid Regex translation; instances retain pattern classification and case behavior.
text.IsWildcardMatch(pattern) and WildcardMatch.IsMatch(text, pattern) match directly without Regex translation or per-match buffers.
new WildcardMatch(pattern) retains its pattern and case behavior. Inspect WildcardRegex for a lazily generated equivalent expression.
new WildcardMatchRegex(pattern, WildcardOptions.Compiled) compiles Regex execution. The direct engine accepts this flag without additional compilation.
Options: IgnoreCase, CultureInvariant, Singleline, Compiled, and RightToLeft. Combine flags with |.
Start matching
Match strings and character spans. The package targets .NET Standard 2.1, .NET 10, and .NET 11. .NET 8 and 9 use its Standard assembly. .NET Framework is not supported. These examples use the Tedd namespace.
dotnet add package Tedd.WildcardMatchusing Tedd;
// Extension method.
bool first = "report-01.txt"
.IsWildcardMatch("report-??.txt"); // true
// Static method, with case handling.
bool second = WildcardMatch.IsMatch(
"REPORT-01.TXT",
"report-??.txt",
WildcardOptions.IgnoreCase |
WildcardOptions.CultureInvariant); // trueusing System;
using Tedd;
var matcher = new WildcardMatch(
"report-*.txt",
WildcardOptions.CultureInvariant,
TimeSpan.FromMilliseconds(100));
bool first = matcher.IsMatch("report-01.txt");
bool second = matcher.IsMatch("report-summary.txt");
// Generated regex: ^report-.*\.txt$
Console.WriteLine(matcher.WildcardRegex);using System;
using Tedd;
ReadOnlySpan<char> input = "[report-01.txt]".AsSpan(1, 13);
ReadOnlySpan<char> pattern = "report-??.txt".AsSpan();
bool first = WildcardMatch.IsMatch(input, pattern);
bool second = input.IsWildcardMatch(pattern);
var matcher = new WildcardMatch(pattern); // Copies the pattern once.
bool third = matcher.IsMatch(input);Static span calls borrow both slices. Reusable matchers borrow each input and own a copy of a span pattern. Ordinary matching avoids creating strings. Span<char> also supports the extension method; ReadOnlyMemory<char> callers use .Span. Keep buffers stable during each call. Default spans represent empty text. Timeout diagnostics materialize their text; .NET 11 vertical-tab normalization with numeric IgnorePatternWhitespace options uses stack or pooled scratch storage.
The default timeout is infinite. Instance constructors accept a TimeSpan; a timeout raises RegexMatchTimeoutException.
Measured on .NET 10
Compare matching throughput across short inputs and strings over 1,000 characters. Select a short-string pattern to see literal, question-mark, and multi-star workloads. Higher bars mean faster matching.
Both engines receive identical string inputs: direct static and reused calls, plus Regex static, reused, and compiled calls. Reused instances are prepared before timing; static calls include their per-call setup.
Each graph includes every tested library and API. Full results, confidence intervals, and construction costs are available in the linked reports.
report-??.txt · millions of matches/sReusable direct matcher: 4.24× the throughput of the next-fastest tested library on this workload.
*alpha*beta??*omega* · millions of matches/sReusable direct matcher: 1.17× the throughput of the next-fastest tested library on this workload.
Measured 2026-10-02 · AMD Ryzen 9 5950X · .NET 10 · three processes with optimized JIT. Reusable patterns are prepared before timing. Results depend on workload and API lifetime; full timings, intervals, allocations and configuration are linked below. Library source: 5043403.