STRling 3.0.0
dotnet add package STRling --version 3.0.0
NuGet\Install-Package STRling -Version 3.0.0
<PackageReference Include="STRling" Version="3.0.0" />
<PackageVersion Include="STRling" Version="3.0.0" />
<PackageReference Include="STRling" />
paket add STRling --version 3.0.0
#r "nuget: STRling, 3.0.0"
#:package STRling@3.0.0
#addin nuget:?package=STRling&version=3.0.0
#tool nuget:?package=STRling&version=3.0.0
STRling - C# Binding
Part of the STRling Project
<table> <tr> <td style="padding: 10px;"><img src="https://raw.githubusercontent.com/strling-lang/.github/refs/heads/main/strling_silver_bell.png" alt="STRling Logo" width="100" /></td> <td style="padding: 10px;"> <strong>The Universal Regular Expression Compiler.</strong><br><br> STRling is a next-generation production-grade syntax designed to make Regex readable, maintainable, and robust. It abstracts the cryptic nature of raw regex strings into a clean, object-oriented, and strictly typed interface that compiles to standard PCRE2 (or native) patterns. </td> </tr> </table>
💿 Installation
cd bindings/csharp
dotnet build
📦 Usage
Here is how to match a US Phone number (e.g., 555-0199) using STRling in C#:
using Strling.Simply;
using System.Text.RegularExpressions;
// Build the phone pattern using the Simply fluent API
// Match: ^(\d{3})[-. ]?(\d{3})[-. ]?(\d{4})$
var phonePattern = S.Merge(
S.Start(), // Start of line
S.Digit(3).Capture(), // 3 digits (area code)
S.AnyOf("-. ").May(), // Optional separator
S.Digit(3).Capture(), // 3 digits (exchange)
S.AnyOf("-. ").May(), // Optional separator
S.Digit(4).Capture(), // 4 digits (line number)
S.End() // End of line
);
// Compile to regex string and test
var regex = new Regex(phonePattern.Compile());
Console.WriteLine(regex.IsMatch("555-123-4567")); // True
Note: This compiles to the optimized regex:
^(\d{3})[-. ]?(\d{3})[-. ]?(\d{4})$
🚀 Why STRling?
Regular Expressions are powerful but notorious for being "write-only" code. STRling solves this by treating Regex as Software, not a string.
- 🧩 Composability: Regex strings are hard to merge. STRling lets you build reusable components (e.g.,
ip_address,email) and safely compose them into larger patterns without breaking operator precedence or capturing groups. - 🛡️ Type Safety: Catch syntax errors, invalid ranges, and incompatible flags at compile time inside your IDE, not at runtime when your app crashes.
- 🧠 IntelliSense & Autocomplete: Stop memorizing cryptic codes like
(?<=...). Use fluent, self-documenting methods likeS.LookBehind(...)with full IDE discovery. - 📖 Readability First: Code is read far more often than it is written. STRling patterns describe intent, making them understandable to junior developers and future maintainers instantly.
- 🌍 Polyglot Engine: One mental model, 17 languages. Whether you are writing Rust, Python, or TypeScript, the syntax and behavior remain identical.
🏗️ Architecture
STRling follows a strict compiler pipeline architecture to ensure consistency across all ecosystems:
- Parse:
DSL -> AST(Abstract Syntax Tree)- Converts the human-readable STRling syntax into a structured tree.
- Compile:
AST -> IR(Intermediate Representation)- Transforms the AST into a target-agnostic intermediate representation, optimizing structures like literal sequences.
- Emit:
IR -> Target Regex- Generates the final, optimized regex string for the specific target engine (e.g., PCRE2, JS, Python
re).
- Generates the final, optimized regex string for the specific target engine (e.g., PCRE2, JS, Python
📚 Documentation
- API Reference: Detailed documentation for this binding.
- Project Hub: The main STRling repository.
- Specification: The core grammar and semantic specifications.
🌐 Connect
💖 Support
If you find STRling useful, consider starring the repository and contributing!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 was computed. 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. |
-
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 |
|---|---|---|
| 3.0.0 | 91 | 4/19/2026 |
| 3.0.0-alpha | 100 | 4/19/2026 |