RegexCraft is a fluent C# API for building regular expressions with full IntelliSense-friendly method chaining.
dotnet add package RegexCraftusing RegexCraft;
var pattern = Pattern.StartOfLine
.Exactly(3).Digits
.Then("-")
.Exactly(4).Digits
.EndOfLine;
var regexText = pattern.Build(); // ^\d{3}\-\d{4}$
var isMatch = pattern.Test("555-1234"); // truevar emailLike = Pattern.StartOfLine
.OneOrMore.WordChars
.Then("@")
.OneOrMore.WordChars
.Then(".")
.Between(2, 6).Letters
.EndOfLine;var optionalPlural = Pattern.Then("item").Optional.Then("s");Patterns.Email.Test("user@example.com");
Patterns.Url.Test("https://example.com");
Patterns.IpV4.Test("192.168.1.1");
Patterns.Phone.Test("555-1234");
Patterns.Guid.Test("550e8400-e29b-41d4-a716-446655440000");var explanation = Pattern.StartOfLine
.Exactly(3).Digits
.Then("-")
.Exactly(4).Digits
.EndOfLine
.Explain();
// Start of line, exactly 3 digits, literal '-', exactly 4 digits, end of linevar generated = Pattern.StartOfLine
.OneOrMore.Digits
.EndOfLine
.ToGeneratedRegex("DigitsOnly");
// [GeneratedRegex(@"^\d+$")]
// private static partial Regex DigitsOnly();RegexCraft includes strict quality automation:
- Coverage gate: line coverage must be at least 95% and branch coverage at least 85%.
- Mutation gate: Stryker mutation score thresholds are high: 95, low: 90, break: 85 (see
stryker-config.json).
Run everything locally:
./scripts/quality-gates.shOr run steps manually:
dotnet test RegexCraft.sln /p:CollectCoverage=true /p:Threshold=95%2c85 /p:ThresholdType=line%2cbranch /p:ThresholdStat=total
dotnet tool restore
dotnet stryker --config-file stryker-config.jsonCI workflow: .github/workflows/quality-gates.yml.
Public API compatibility is tracked via:
api/PublicApi.Shipped.txttests/RegexCraft.Tests/ApiCompatibilityBaselineTests.cs
If public APIs intentionally change, update the baseline file and record the change in CHANGELOG.md.
Run BenchmarkDotNet benchmarks locally:
./scripts/run-benchmarks.sh- Version and package metadata live in
src/RegexCraft/RegexCraft.csproj. - Changelog is tracked in
CHANGELOG.md. - Tag a release with
v*(for examplev1.0.1) to trigger:.github/workflows/publish-nuget.yml- build + test +
dotnet pack - publish to NuGet using
NUGET_API_KEYsecret.
MIT