* → 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 (C#) execution or the WildcardMatch (C#)Regex string engine, with reusable matchers, case options, and explicit timeouts.
2.09× 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 (C#).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.
Compare direct static and reused calls, Regex static, reused and compiled calls, three managed packages, and native Krauss, Git wildmatch, Zema wildcards and PCRE2 JIT. Reused instances are prepared before timing; static calls include their per-call setup.
Each graph compares the reusable direct Tedd matcher with the managed competitors and the fastest measured call/storage mode for each native library. The tables include all 110 cases: 100 matching comparisons, eight construction cases and two transition controls. Native buffer modes and suppressed calls remain individually visible.
report-??.txt · millions of matches/sReusable direct matcher: 2.09× the throughput of the next-fastest tested library on this workload.
*alpha*beta??*omega* · millions of matches/sReusable direct matcher: 1.28× the throughput of the next-fastest tested library on this workload.
100 cases · lower time is better
| Workload | Implementation | Call / storage | Mean ns | Error ± ns | Managed B/match |
|---|---|---|---|---|---|
| Literal | Tedd direct · reused | managed | 5.233 | 0.002 | 0 |
| Literal | Krauss (C++) | batch_shared | 9.325 | 0.003 | 0 |
| Literal | Krauss (C++) | batch_cloned | 9.420 | 0.179 | 0 |
| Literal | Krauss (C++) | suppressed_cloned | 10.516 | 0.007 | 0 |
| Literal | Krauss (C++) | suppressed_shared | 10.809 | 0.003 | 0 |
| Literal | Krauss (C++) | normal_cloned | 11.116 | 0.010 | 0 |
| Literal | Krauss (C++) | normal_shared | 11.413 | 0.005 | 0 |
| Literal | Tedd direct · static | managed | 14.100 | 0.019 | 0 |
| Literal | PCRE2 JIT (C) | batch_shared | 15.810 | 0.006 | 0 |
| Literal | DotNet.Glob (C#) | managed | 15.868 | 0.026 | 0 |
| Literal | PCRE2 JIT (C) | batch_cloned | 16.053 | 0.077 | 0 |
| Literal | Git wildmatch (C) | batch_shared | 26.025 | 0.021 | 0 |
| Literal | Git wildmatch (C) | batch_cloned | 26.262 | 0.322 | 0 |
| Literal | Git wildmatch (C) | suppressed_cloned | 27.235 | 0.021 | 0 |
| Literal | Git wildmatch (C) | suppressed_shared | 27.478 | 0.009 | 0 |
| Literal | Git wildmatch (C) | normal_cloned | 27.814 | 0.013 | 0 |
| Literal | Git wildmatch (C) | normal_shared | 28.173 | 0.011 | 0 |
| Literal | WildcardMatch (C#) | managed | 29.964 | 0.062 | 48 |
| Literal | Tedd Regex · compiled | managed | 36.500 | 0.223 | 0 |
| Literal | FastWildcard (C#) | managed | 74.317 | 0.687 | 0 |
| Literal | Zema wildcards (C++) | batch_cloned | 78.486 | 0.555 | 0 |
| Literal | Zema wildcards (C++) | suppressed_cloned | 78.923 | 0.899 | 0 |
| Literal | Zema wildcards (C++) | batch_shared | 79.615 | 1.495 | 0 |
| Literal | Zema wildcards (C++) | normal_cloned | 79.641 | 0.459 | 0 |
| Literal | Zema wildcards (C++) | normal_shared | 79.766 | 0.591 | 0 |
| Literal | Zema wildcards (C++) | suppressed_shared | 80.353 | 1.980 | 0 |
| Literal | Tedd Regex · reused | managed | 87.401 | 0.203 | 0 |
| Literal | Tedd Regex · static | managed | 219.419 | 4.298 | 120 |
| Question marks | Tedd direct · reused | managed | 4.562 | 0.001 | 0 |
| Question marks | Krauss (C++) | batch_cloned | 9.557 | 0.007 | 0 |
| Question marks | Krauss (C++) | batch_shared | 9.560 | 0.005 | 0 |
| Question marks | Krauss (C++) | suppressed_cloned | 11.029 | 0.004 | 0 |
| Question marks | Krauss (C++) | suppressed_shared | 11.329 | 0.006 | 0 |
| Question marks | Krauss (C++) | normal_cloned | 11.337 | 0.005 | 0 |
| Question marks | Krauss (C++) | normal_shared | 11.634 | 0.003 | 0 |
| Question marks | PCRE2 JIT (C) | batch_cloned | 16.183 | 0.006 | 0 |
| Question marks | PCRE2 JIT (C) | batch_shared | 16.191 | 0.009 | 0 |
| Question marks | Tedd direct · static | managed | 19.155 | 0.007 | 0 |
| Question marks | DotNet.Glob (C#) | managed | 22.198 | 0.058 | 0 |
| Question marks | Git wildmatch (C) | batch_cloned | 28.950 | 0.094 | 0 |
| Question marks | Git wildmatch (C) | batch_shared | 28.987 | 0.063 | 0 |
| Question marks | Git wildmatch (C) | suppressed_cloned | 30.269 | 0.059 | 0 |
| Question marks | Git wildmatch (C) | suppressed_shared | 30.645 | 0.056 | 0 |
| Question marks | Git wildmatch (C) | normal_cloned | 31.785 | 0.074 | 0 |
| Question marks | Git wildmatch (C) | normal_shared | 32.079 | 0.088 | 0 |
| Question marks | WildcardMatch (C#) | managed | 35.021 | 0.111 | 48 |
| Question marks | Tedd Regex · compiled | managed | 37.433 | 0.144 | 0 |
| Question marks | Zema wildcards (C++) | batch_cloned | 81.219 | 0.558 | 0 |
| Question marks | Zema wildcards (C++) | suppressed_cloned | 81.357 | 0.625 | 0 |
| Question marks | Zema wildcards (C++) | normal_cloned | 81.729 | 0.403 | 0 |
| Question marks | Zema wildcards (C++) | suppressed_shared | 81.924 | 0.590 | 0 |
| Question marks | Tedd Regex · reused | managed | 82.387 | 0.280 | 0 |
| Question marks | Zema wildcards (C++) | normal_shared | 82.448 | 0.613 | 0 |
| Question marks | Zema wildcards (C++) | batch_shared | 83.047 | 2.153 | 0 |
| Question marks | FastWildcard (C#) | managed | 83.305 | 0.166 | 0 |
| Question marks | Tedd Regex · static | managed | 167.174 | 0.859 | 136 |
| Multiple stars | Tedd direct · reused | managed | 6.622 | 0.062 | 0 |
| Multiple stars | Krauss (C++) | batch_shared | 9.582 | 0.042 | 0 |
| Multiple stars | Krauss (C++) | batch_cloned | 9.602 | 0.046 | 0 |
| Multiple stars | Krauss (C++) | suppressed_cloned | 10.976 | 0.019 | 0 |
| Multiple stars | Krauss (C++) | suppressed_shared | 11.296 | 0.029 | 0 |
| Multiple stars | Krauss (C++) | normal_cloned | 11.301 | 0.026 | 0 |
| Multiple stars | Krauss (C++) | normal_shared | 11.603 | 0.041 | 0 |
| Multiple stars | PCRE2 JIT (C) | batch_shared | 22.487 | 0.088 | 0 |
| Multiple stars | PCRE2 JIT (C) | batch_cloned | 22.515 | 0.088 | 0 |
| Multiple stars | Git wildmatch (C) | batch_shared | 28.240 | 0.019 | 0 |
| Multiple stars | Git wildmatch (C) | batch_cloned | 28.904 | 0.264 | 0 |
| Multiple stars | Git wildmatch (C) | suppressed_cloned | 29.704 | 0.021 | 0 |
| Multiple stars | Git wildmatch (C) | normal_cloned | 30.014 | 0.020 | 0 |
| Multiple stars | Git wildmatch (C) | suppressed_shared | 31.601 | 0.058 | 0 |
| Multiple stars | Git wildmatch (C) | normal_shared | 31.918 | 0.057 | 0 |
| Multiple stars | Tedd direct · static | managed | 35.119 | 0.010 | 0 |
| Multiple stars | Tedd Regex · compiled | managed | 52.236 | 0.281 | 0 |
| Multiple stars | DotNet.Glob (C#) | managed | 59.702 | 0.552 | 0 |
| Multiple stars | FastWildcard (C#) | managed | 68.088 | 0.045 | 0 |
| Multiple stars | WildcardMatch (C#) | managed | 136.359 | 1.767 | 479 |
| Multiple stars | Zema wildcards (C++) | batch_shared | 152.514 | 0.454 | 0 |
| Multiple stars | Zema wildcards (C++) | batch_cloned | 152.846 | 0.351 | 0 |
| Multiple stars | Zema wildcards (C++) | suppressed_cloned | 153.148 | 0.300 | 0 |
| Multiple stars | Zema wildcards (C++) | suppressed_shared | 154.528 | 1.191 | 0 |
| Multiple stars | Zema wildcards (C++) | normal_shared | 154.918 | 0.452 | 0 |
| Multiple stars | Zema wildcards (C++) | normal_cloned | 157.228 | 3.112 | 0 |
| Multiple stars | Tedd Regex · reused | managed | 216.131 | 1.564 | 0 |
| Multiple stars | Tedd Regex · static | managed | 289.405 | 1.471 | 104 |
| Long text | Tedd direct · reused | managed | 183.406 | 1.898 | 0 |
| Long text | Tedd direct · static | managed | 222.323 | 0.503 | 0 |
| Long text | Krauss (C++) | batch_shared | 234.287 | 0.598 | 0 |
| Long text | Krauss (C++) | batch_cloned | 235.801 | 0.417 | 0 |
| Long text | FastWildcard (C#) | managed | 281.658 | 0.615 | 0 |
| Long text | Tedd Regex · compiled | managed | 395.955 | 0.872 | 0 |
| Long text | Git wildmatch (C) | batch_shared | 841.494 | 0.908 | 0 |
| Long text | Git wildmatch (C) | batch_cloned | 841.936 | 0.806 | 0 |
| Long text | PCRE2 JIT (C) | batch_shared | 1466.610 | 7.726 | 0 |
| Long text | PCRE2 JIT (C) | batch_cloned | 1472.601 | 11.717 | 0 |
| Long text | DotNet.Glob (C#) | managed | 7312.846 | 78.750 | 0 |
| Long text | WildcardMatch (C#) | managed | 13473.288 | 192.232 | 44472 |
| Long text | Zema wildcards (C++) | batch_shared | 22050.382 | 11.732 | 0 |
| Long text | Zema wildcards (C++) | batch_cloned | 22056.586 | 16.876 | 0 |
| Long text | Tedd Regex · reused | managed | 24308.254 | 12.887 | 0 |
| Long text | Tedd Regex · static | managed | 24410.997 | 16.692 | 192 |
8 cases · excluded from reused matching
| Pattern | Implementation | Mean ns | Error ± ns | Managed B/construction |
|---|---|---|---|---|
*a?c*e* | Tedd direct · reused | 110.763 | 1.167 | 296 |
*a?c*e* | Tedd Regex · reused | 2100.764 | 21.004 | 2000 |
*a?c*e* | Tedd Regex · compiled | 15969.078 | 96.616 | 12696 |
*a?c*e* | DotNet.Glob (C#) | 802.038 | 6.371 | 1792 |
report-??.txt | Tedd direct · reused | 55.101 | 0.232 | 224 |
report-??.txt | Tedd Regex · reused | 1905.110 | 16.509 | 2024 |
report-??.txt | Tedd Regex · compiled | 9969.461 | 35.249 | 8448 |
report-??.txt | DotNet.Glob (C#) | 666.696 | 9.938 | 976 |
2 cases · trivial native function
| Call | Mean ns | Error ± ns |
|---|---|---|
| Normal | 3.271 | 0.001 |
| Suppressed | 1.505 | 0.000 |
Native batch calls cross once per 256 matches; normal and suppressed calls cross once per input into the identical export. Suppression is qualified only for the three short Krauss, Git and Zema fixtures. PCRE2 and long calls use ordinary transitions. The trivial control is not subtracted from matcher timings. Cloned storage owns each input buffer; shared storage reuses buffers for equal input values. Every match executes; results are not cached.
Measured 2026-10-15 · AMD Ryzen 9 5950X · .NET 10.0.13 (10.0.13, 10.0.1326.50504) · BenchmarkDotNet 0.15.8. Three launches, three warmups, ten 100 ms measured iterations, CPU 30 affinity, tiering disabled. Error is the 99.9% confidence-interval half-width over retained iteration measurements. Managed UTF-16 and native NUL-free ASCII buffers, encoding and reusable patterns are prepared before timing. Native allocation is not measured by managed B/match. Results depend on corpus and API lifetime and do not establish a universal ranking. The measured source snapshot has package metadata 2.2.0; release 2.3.0 contains the same matcher source. Library source: f3340d5.