STRling.FSharp 3.0.0

dotnet add package STRling.FSharp --version 3.0.0
                    
NuGet\Install-Package STRling.FSharp -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.FSharp" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="STRling.FSharp" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="STRling.FSharp" />
                    
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.FSharp --version 3.0.0
                    
#r "nuget: STRling.FSharp, 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.FSharp@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.FSharp&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=STRling.FSharp&version=3.0.0
                    
Install as a Cake Tool

STRling - F# 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

Install via NuGet:

dotnet add package STRling.FSharp

📦 Usage

Here is how to match a US Phone number (e.g., 555-0199) using STRling's Simply API in F#:

open STRling.Simply

// Build a US phone number pattern: ^(\d{3})[-. ]?(\d{3})[-. ]?(\d{4})$
let phone =
    merge [
        start ()
        capture (digit 3)
        may (anyOf "-. ")
        capture (digit 3)
        may (anyOf "-. ")
        capture (digit 4)
        end' ()
    ]

// Compile to regex string
let regex = phone |> compile
printfn "%s" regex
// Output: ^(\d{3})[-. ]?(\d{3})[-. ]?(\d{4})$

DSL String Parsing

Alternatively, you can parse a DSL string directly using the Parser:

open STRling.Core

// Parse a DSL pattern string
let dsl = "start capture(digit(3)) may(anyOf('-. ')) capture(digit(3)) may(anyOf('-. ')) capture(digit(4)) end"
let ast = Parser.parse dsl

// Compile the AST to IR and emit
let ir = Compiler.compile ast
let regex = Emitters.PCRE2.emit ir
printfn "%s" regex

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 simply.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.

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 95 4/19/2026