A fluent, immutable API for building .NET regular expressions, plus the tools to understand, test, secure and ship them.
📖 Read the documentation · Quick Start · Examples · API Reference · Playground
All documentation lives on the documentation site. It covers every feature with run-verified examples, the full API reference and the upgrade guide. This README is only a short introduction.
dotnet add package Masterly.FluentRegexThe package includes the source generator and analyzers. It targets .NET 10, .NET 8 and .NET Standard 2.1. See Installation for the companion packages and the command-line tool.
using Masterly.FluentRegex;
Pattern pattern = Pattern.With
.StartOfLine
.Digit.Repeat.OneOrMore
.Literal("-")
.Word.Repeat.Times(3, 5)
.EndOfLine;
bool isMatch = pattern.IsMatch("123-abc"); // true
bool noMatch = pattern.IsMatch("abc-123"); // false
string regex = pattern.ToString(); // ^\d+-\w{3,5}$Continue with the Quick Start, or try it in the browser in the Playground.
| Build | A readable fluent builder with automatic escaping, groups, lookaround, composition, semantic rules such as Luhn checks, and a library of common patterns |
| Match | Matching, replacing and splitting, typed extraction, typed templates, streaming, PII redaction and Unicode scripts |
| Prove | Equivalence proofs with counterexamples, language facts, a verified optimizer and ReDoS analysis |
| Test | Explain and debug, match tracing, regex coverage, test data, property testing, a backtracking profiler and railroad diagrams |
| Ship | Regex to fluent code, learning from examples, AI drafting, JavaScript and JSON Schema export, SQL regex dialects and SQL LIKE |
| Integrate | EF Core, ASP.NET Core, xUnit, compile-time checks and the command-line tool |
| Package | Adds |
|---|---|
Masterly.FluentRegex |
The library, with the source generator and analyzers |
Masterly.FluentRegex.EntityFrameworkCore |
Patterns in LINQ queries, run as the database's own regex |
Masterly.FluentRegex.AspNetCore |
Route constraints such as {id:pattern(sku)} |
Masterly.FluentRegex.Xunit |
[MatchingData] and [NonMatchingData] theory data |
Masterly.FluentRegex.AI |
Drafts patterns with Claude and verifies them locally |
Masterly.FluentRegex.Tool |
The fluentregex command-line tool |
Contributions are welcome. For major changes, please open an issue first to discuss what you would like to change.
git clone https://github.com/a7mdfre7at/Masterly.FluentRegex.git
cd Masterly.FluentRegex
dotnet test # .NET 8 and .NET 10
dotnet run --project samples/Masterly.FluentRegex.Showcase # a tour of every featureThe documentation site is in website/. Run it locally with npm ci and npm start in that folder.
MIT. See LICENSE.