STRling 3.0.0

dotnet add package STRling --version 3.0.0
                    
NuGet\Install-Package STRling -Version 3.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="STRling" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="STRling" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="STRling" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add STRling --version 3.0.0
                    
#r "nuget: STRling, 3.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package STRling@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=STRling&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=STRling&version=3.0.0
                    
Install as a Cake Tool

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 like S.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:

  1. Parse: DSL -> AST (Abstract Syntax Tree)
    • Converts the human-readable STRling syntax into a structured tree.
  2. Compile: AST -> IR (Intermediate Representation)
    • Transforms the AST into a target-agnostic intermediate representation, optimizing structures like literal sequences.
  3. Emit: IR -> Target Regex
    • Generates the final, optimized regex string for the specific target engine (e.g., PCRE2, JS, Python re).

📚 Documentation

🌐 Connect

GitHub

💖 Support

If you find STRling useful, consider starring the repository and contributing!

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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