Resharp 1.0.0
dotnet add package Resharp --version 1.0.0
NuGet\Install-Package Resharp -Version 1.0.0
<PackageReference Include="Resharp" Version="1.0.0" />
<PackageVersion Include="Resharp" Version="1.0.0" />
<PackageReference Include="Resharp" />
paket add Resharp --version 1.0.0
#r "nuget: Resharp, 1.0.0"
#:package Resharp@1.0.0
#addin nuget:?package=Resharp&version=1.0.0
#tool nuget:?package=Resharp&version=1.0.0
RE#
A high-performance, Symbolic Automata based regex engine with first-class support for intersection and complement operations.
RE# compiles patterns into deterministic automata. All matching is non-backtracking with guaranteed linear-time execution. RE# extends System.Text.RegularExpressions syntax with intersection (&), complement (~), and a universal wildcard (_), enabling patterns that are impossible or impractical to express with standard regex.
web playground | paper | blog post
Install
dotnet add package Resharp
Usage
var re = new Resharp.Regex(@"\w+");
re.IsMatch("hello"); // true
re.Count("one two three"); // 3
re.Replace("a1b2", "X"); // "aXbX"
let re = Resharp.Regex(@"hello.*world")
re.Matches("hello world!")
Syntax extensions
RE# supports standard .NET regex syntax plus three extensions:
_ -- universal wildcard
Matches any character including newlines. Equivalent to [\s\S].
_* any string (including empty)
_{5,10} any string of 5-10 characters
& -- intersection
Both sides must match. Intersection has higher precedence than alternation.
_*cat_*&_*dog_* contains both "cat" and "dog"
_*cat_*&_*dog_*&_{5,30} ...and is 5-30 characters long
~(...) -- complement
Matches everything the inner pattern does not match.
~(_*\d\d_*) does not contain two consecutive digits
~(.*\n\n.*) does not contain a double newline
Combining operators
F.*&~(.*Finn) starts with 'F', does not end with "Finn"
~(_*\d\d_*)&[a-zA-Z\d]{8,} 8+ alphanumeric, no consecutive digits
Performance
RE# uses Automata-based matching with several optimizations: start-set inference, literal prefix scanning, and optional full DFA precompilation. RE# shares many optimizations with .NET's (and .NonBacktracking even shares some RE# techniques and strengths :^)) but RE# is designed from the ground up and returns a different kind of matches (leftmost-longest).
On curated benchmarks from rebar (AMD Ryzen 7 5800X, .NET 10.0):
| Pattern | RE# | .NET Compiled | Speedup |
|---|---|---|---|
| date validation | 1,698 us | 261,957 us | 154x |
| dictionary search | 412 us | 14,726 us | 36x |
RE# particularly excels with large patterns. The "monster" benchmarks test dictionary-sized alternations (thousands of alternatives), case-insensitive unicode matching, and context-windowed variants. Here is a little comparison of RE# with .NET's compiled regex engine on these patterns, you can also find wider comparisons in the paper:
| Pattern | RE# | .NET Compiled | Speedup |
|---|---|---|---|
| dictionary, case-insensitive unicode | 603 us | 29,551 us | 49x |
| dictionary, case-insensitive | 631 us | 49,685 us | 79x |
| unicode dictionary | 326 us | 61,853 us | 190x |
| unicode dictionary, case-insensitive | 331 us | 483,251 us | 1,460x |
| dictionary + context window | 680 us | 24,470,445 us | 35,963x |
For throughput-critical paths, use ValueMatches for zero-allocation matching and ResharpOptions.HighThroughputDefaults for more aggressive optimization.
let re = Resharp.Regex("pattern", ResharpOptions.HighThroughputDefaults)
use slices = re.ValueMatches(chars)
for s in slices do
printfn $"match at {s.Index}..{s.Index + s.Length}"
'Is it always faster?'
No, but it can be orders of magnitude faster on large patterns and inputs. RE# is designed for scenarios where regex performance is critical and patterns are complex. If the task is simple enough that you don't need regex at all, RE# may not be the best choice. If you're only searching for a small set of literals, using SearchValues can yield better results. RE# shines when you need the full power of regex with large patterns and inputs.
Documentation
- Syntax reference -- full pattern syntax including
&,~,_ - API reference -- all public types and methods
Examples
Runnable scripts in examples/:
| File | Description |
|---|---|
| basic-syntax.fsx | wildcards, intersection, complement |
| paragraph.fsx | paragraph extraction with complement and intersection |
| validation.fsx | date, IP, password validation with intersection |
| replace.fsx | string and function-based replacement |
| lookaround.fsx | lookahead, lookbehind, combined with intersection |
| high-throughput.fsx | zero-allocation matching for large inputs |
| Basic.cs | C# usage |
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 33 | 2/22/2026 |
| 0.2.2-library | 190 | 9/29/2025 |
| 0.2.1 | 429 | 9/27/2025 |
| 0.2.1-library | 110 | 9/27/2025 |
| 0.1.34 | 611 | 2/22/2025 |
| 0.1.33 | 335 | 11/30/2024 |
| 0.1.25 | 765 | 6/27/2024 |
| 0.1.24 | 176 | 6/27/2024 |
| 0.1.17 | 212 | 6/8/2024 |
| 0.0.23 | 142 | 5/19/2024 |
| 0.0.22 | 144 | 5/7/2024 |
| 0.0.20 | 130 | 5/5/2024 |
| 0.0.1-library | 188 | 12/11/2024 |