Pattern matching for .NET

Highly optimized.
Fast wildcard matching.

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.

NuGet package version Build and test status
  • .NET Standard 2.1 · .NET 10 / 11
  • No runtime package dependencies
  • LGPL-2.1
WILDCARD PATTERNCase-sensitive matching
report-??.txt
Two characters between the prefix and extension.
report-01.txtMATCH
report-aa.txtMATCH
report-1.txtNO MATCH
report-001.txtNO MATCH
EQUIVALENT REGEX^report-..\.txt$
Both engines share wildcard semantics. WildcardRegex exposes the equivalent anchored expression for inspection.

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

Small syntax.
Useful control.

Patterns use two operators. Every other character is literal, including dots, brackets, and regular-expression punctuation.

01 / Sequence

* → zero or more

report-*.txt matches report-.txt and report-summary.txt. Use stars at both ends for substring matching.

02 / Character

? → exactly one

report-??.txt requires two UTF-16 code units in that position. It matches report-01.txt.

03 / Literal

Punctuation stays literal

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

The right lifetime
for your pattern.

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.

01 / Convenient

Extension or static call

text.IsWildcardMatch(pattern) and WildcardMatch (C#).IsMatch(text, pattern) match directly without Regex translation or per-match buffers.

02 / Repeated matches

Reusable instance

new WildcardMatch(pattern) retains its pattern and case behavior. Inspect WildcardRegex for a lazily generated equivalent expression.

03 / Regex execution

Compiled Regex instance

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

Install. Match.
Reuse.

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.WildcardMatch
Convenience API
using 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); // true
Reusable pattern with a timeout
using 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);
Borrow string, array, or stack-buffer slices
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.

Bound execution for untrusted patterns.

The default timeout is infinite. Instance constructors accept a TimeSpan; a timeout raises RegexMatchTimeoutException.

API source ↗

Measured on .NET 10

Short strings.
Long strings.

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.

4–16 UTF-16 code units
Short strings · matching throughputQuestion marksPattern: report-??.txt · millions of matches/s
Tedd direct · reused
219.18
Krauss (C++) · batch_cloned
104.63
PCRE2 JIT (C) · batch_cloned
61.79
DotNet.Glob (C#)
45.05
Git wildmatch (C) · batch_cloned
34.54
WildcardMatch (C#)
28.55
Zema wildcards (C++) · batch_cloned
12.31
FastWildcard (C#)
12.00

Reusable direct matcher: 2.09× the throughput of the next-fastest tested library on this workload.

Every input exceeds 1,000 UTF-16 code units
Long strings · matching throughputLong textPattern: *alpha*beta??*omega* · millions of matches/s
Tedd direct · reused
5.45
Krauss (C++) · batch_shared
4.27
FastWildcard (C#)
3.55
Git wildmatch (C) · batch_shared
1.19
PCRE2 JIT (C) · batch_shared
0.68
DotNet.Glob (C#)
0.14
WildcardMatch (C#)
0.07
Zema wildcards (C++) · batch_shared
0.05

Reusable direct matcher: 1.28× the throughput of the next-fastest tested library on this workload.

All matching comparisons

100 cases · lower time is better

Every managed and native matching call and storage mode
WorkloadImplementationCall / storageMean nsError ± nsManaged B/match
LiteralTedd direct · reusedmanaged5.2330.0020
LiteralKrauss (C++)batch_shared9.3250.0030
LiteralKrauss (C++)batch_cloned9.4200.1790
LiteralKrauss (C++)suppressed_cloned10.5160.0070
LiteralKrauss (C++)suppressed_shared10.8090.0030
LiteralKrauss (C++)normal_cloned11.1160.0100
LiteralKrauss (C++)normal_shared11.4130.0050
LiteralTedd direct · staticmanaged14.1000.0190
LiteralPCRE2 JIT (C)batch_shared15.8100.0060
LiteralDotNet.Glob (C#)managed15.8680.0260
LiteralPCRE2 JIT (C)batch_cloned16.0530.0770
LiteralGit wildmatch (C)batch_shared26.0250.0210
LiteralGit wildmatch (C)batch_cloned26.2620.3220
LiteralGit wildmatch (C)suppressed_cloned27.2350.0210
LiteralGit wildmatch (C)suppressed_shared27.4780.0090
LiteralGit wildmatch (C)normal_cloned27.8140.0130
LiteralGit wildmatch (C)normal_shared28.1730.0110
LiteralWildcardMatch (C#)managed29.9640.06248
LiteralTedd Regex · compiledmanaged36.5000.2230
LiteralFastWildcard (C#)managed74.3170.6870
LiteralZema wildcards (C++)batch_cloned78.4860.5550
LiteralZema wildcards (C++)suppressed_cloned78.9230.8990
LiteralZema wildcards (C++)batch_shared79.6151.4950
LiteralZema wildcards (C++)normal_cloned79.6410.4590
LiteralZema wildcards (C++)normal_shared79.7660.5910
LiteralZema wildcards (C++)suppressed_shared80.3531.9800
LiteralTedd Regex · reusedmanaged87.4010.2030
LiteralTedd Regex · staticmanaged219.4194.298120
Question marksTedd direct · reusedmanaged4.5620.0010
Question marksKrauss (C++)batch_cloned9.5570.0070
Question marksKrauss (C++)batch_shared9.5600.0050
Question marksKrauss (C++)suppressed_cloned11.0290.0040
Question marksKrauss (C++)suppressed_shared11.3290.0060
Question marksKrauss (C++)normal_cloned11.3370.0050
Question marksKrauss (C++)normal_shared11.6340.0030
Question marksPCRE2 JIT (C)batch_cloned16.1830.0060
Question marksPCRE2 JIT (C)batch_shared16.1910.0090
Question marksTedd direct · staticmanaged19.1550.0070
Question marksDotNet.Glob (C#)managed22.1980.0580
Question marksGit wildmatch (C)batch_cloned28.9500.0940
Question marksGit wildmatch (C)batch_shared28.9870.0630
Question marksGit wildmatch (C)suppressed_cloned30.2690.0590
Question marksGit wildmatch (C)suppressed_shared30.6450.0560
Question marksGit wildmatch (C)normal_cloned31.7850.0740
Question marksGit wildmatch (C)normal_shared32.0790.0880
Question marksWildcardMatch (C#)managed35.0210.11148
Question marksTedd Regex · compiledmanaged37.4330.1440
Question marksZema wildcards (C++)batch_cloned81.2190.5580
Question marksZema wildcards (C++)suppressed_cloned81.3570.6250
Question marksZema wildcards (C++)normal_cloned81.7290.4030
Question marksZema wildcards (C++)suppressed_shared81.9240.5900
Question marksTedd Regex · reusedmanaged82.3870.2800
Question marksZema wildcards (C++)normal_shared82.4480.6130
Question marksZema wildcards (C++)batch_shared83.0472.1530
Question marksFastWildcard (C#)managed83.3050.1660
Question marksTedd Regex · staticmanaged167.1740.859136
Multiple starsTedd direct · reusedmanaged6.6220.0620
Multiple starsKrauss (C++)batch_shared9.5820.0420
Multiple starsKrauss (C++)batch_cloned9.6020.0460
Multiple starsKrauss (C++)suppressed_cloned10.9760.0190
Multiple starsKrauss (C++)suppressed_shared11.2960.0290
Multiple starsKrauss (C++)normal_cloned11.3010.0260
Multiple starsKrauss (C++)normal_shared11.6030.0410
Multiple starsPCRE2 JIT (C)batch_shared22.4870.0880
Multiple starsPCRE2 JIT (C)batch_cloned22.5150.0880
Multiple starsGit wildmatch (C)batch_shared28.2400.0190
Multiple starsGit wildmatch (C)batch_cloned28.9040.2640
Multiple starsGit wildmatch (C)suppressed_cloned29.7040.0210
Multiple starsGit wildmatch (C)normal_cloned30.0140.0200
Multiple starsGit wildmatch (C)suppressed_shared31.6010.0580
Multiple starsGit wildmatch (C)normal_shared31.9180.0570
Multiple starsTedd direct · staticmanaged35.1190.0100
Multiple starsTedd Regex · compiledmanaged52.2360.2810
Multiple starsDotNet.Glob (C#)managed59.7020.5520
Multiple starsFastWildcard (C#)managed68.0880.0450
Multiple starsWildcardMatch (C#)managed136.3591.767479
Multiple starsZema wildcards (C++)batch_shared152.5140.4540
Multiple starsZema wildcards (C++)batch_cloned152.8460.3510
Multiple starsZema wildcards (C++)suppressed_cloned153.1480.3000
Multiple starsZema wildcards (C++)suppressed_shared154.5281.1910
Multiple starsZema wildcards (C++)normal_shared154.9180.4520
Multiple starsZema wildcards (C++)normal_cloned157.2283.1120
Multiple starsTedd Regex · reusedmanaged216.1311.5640
Multiple starsTedd Regex · staticmanaged289.4051.471104
Long textTedd direct · reusedmanaged183.4061.8980
Long textTedd direct · staticmanaged222.3230.5030
Long textKrauss (C++)batch_shared234.2870.5980
Long textKrauss (C++)batch_cloned235.8010.4170
Long textFastWildcard (C#)managed281.6580.6150
Long textTedd Regex · compiledmanaged395.9550.8720
Long textGit wildmatch (C)batch_shared841.4940.9080
Long textGit wildmatch (C)batch_cloned841.9360.8060
Long textPCRE2 JIT (C)batch_shared1466.6107.7260
Long textPCRE2 JIT (C)batch_cloned1472.60111.7170
Long textDotNet.Glob (C#)managed7312.84678.7500
Long textWildcardMatch (C#)managed13473.288192.23244472
Long textZema wildcards (C++)batch_shared22050.38211.7320
Long textZema wildcards (C++)batch_cloned22056.58616.8760
Long textTedd Regex · reusedmanaged24308.25412.8870
Long textTedd Regex · staticmanaged24410.99716.692192

Pattern construction

8 cases · excluded from reused matching

Pattern construction time and managed allocation
PatternImplementationMean nsError ± nsManaged B/construction
*a?c*e*Tedd direct · reused110.7631.167296
*a?c*e*Tedd Regex · reused2100.76421.0042000
*a?c*e*Tedd Regex · compiled15969.07896.61612696
*a?c*e*DotNet.Glob (C#)802.0386.3711792
report-??.txtTedd direct · reused55.1010.232224
report-??.txtTedd Regex · reused1905.11016.5092024
report-??.txtTedd Regex · compiled9969.46135.2498448
report-??.txtDotNet.Glob (C#)666.6969.938976

Managed / native transition control

2 cases · trivial native function

Normal and suppressed transition control time
CallMean nsError ± ns
Normal3.2710.001
Suppressed1.5050.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.