Regx 0.3.6

dotnet add package Regx --version 0.3.6
NuGet\Install-Package Regx -Version 0.3.6
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="Regx" Version="0.3.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Regx --version 0.3.6
#r "nuget: Regx, 0.3.6"
#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.
// Install Regx as a Cake Addin
#addin nuget:?package=Regx&version=0.3.6

// Install Regx as a Cake Tool
#tool nuget:?package=Regx&version=0.3.6

Regx - Declarative Regex for humans

F# DSL for Regex nuget

#r "nuget: Regx"
open Regx

// Compose a regex for url 

let protocol =
    group {
        capture {
            oneOf {
                verbatimString "http"
                verbatimString "https"
            }
        }
        verbatimString "://"
    }

let subdomain =
    group {
        oneOrMore { wordChar }
        verbatimString "."
    }

let domain =
    group {
        captureAs "domain" { occursBetween 2 256 { wordChar } }
        verbatimString "."
    }

let ending = group { occursBetween 1 8 { wordChar } }

let port =
    group {
        verbatimString ":"
        occursMoreThan 2 { digit }
    }

let path =
    zeroOrMore {
        capture {
            verbatimString "/"
            oneOrMore { wordChar }
        }
    }

let pattern =
    regex {
        mayHave { protocol }
        mayHave { subdomain }
        domain
        ending
        mayHave { port }
        path
    }
    |> Regx.make

// Generates - (?:(http|https):\/\/)?(?:\w+\.)?(?:(?<domain>\w{2,256})\.)(?:\w{1,8})(?::\d{2,})?(\/\w+)*

More examples in tests

DSL What it means
any Dot - Matches any character except linebreaks. Equivalent to [^\n\r].
anyChar Match any - A character set that can be used to match any character, including line breaks, without the dotall flag. Represents [\s\S]
wordChar Matches any word character (alphanumeric & underscore). Only matches low-ascii characters (no accented or non-roman characters). Equivalent to [A-Za-z0-9_]
notWordChar Matches any character that is not a word character (alphanumeric & underscore). Equivalent to [^A-Za-z0-9_]
digit Matches any digit character (0-9). Equivalent to [0-9].
notDigit Matches any character that is not a digit character (0-9). Equivalent to [^0-9].
whiteSpace Matches any whitespace character (spaces, tabs, line breaks).
notWhiteSpace Matches any character that is not a whitespace character (spaces, tabs, line breaks).
charIn Match any character in the set
charNotIn Negate character set - Match any character that is not in the set.
inRange Matches a character having a character code between the two specified characters inclusive.
inList Matches characters in list
beginsWith Enclosed expression occurs in the beginning of the fragment
endsWith Enclosed expression occurs in the end of the fragment
beginsWithString Enclosed expression occurs in the beginning of the fragment
endsWithString Enclosed expression occurs in the end of the fragment
wordBoundary Matches a word boundary position between a word character and non-word character or position (start / end of string).
notWordBoundary Matches any position that is not a word boundary. This matches a position, not a character.
mayHave Matches 0 or 1 of the enclosed fragment, effectively making it optional
fewest Makes the enclosed fragment lazy, causing it to match as few characters as possible.
longest Makes the enclosed fragment Greedily, causing it to match as many characters as possible.
oneOf Acts like a boolean OR. Matches the expression before or after the
oneOrMore Matches 1 or more of the enclosed fragment
zeroOrMore Matches 0 or more of the enclosed fragment
occurs Matches the exact quantity of the enclosed token.
occursMoreThan Matches the specified quantity or more of the enclosed token.
occursBetween Matches a quantity of the enclosed toke in the specified range.
between Match between an open and a closing tag- for balanced captures
capture Grouped capture
captureAs Named group capture
group Non-capturing group
refGroupNo \1 - Numeric reference - Matches the results of a capture group.
refGroupName \k<name> - Group name reference - Matches the results of a named capture group.
positiveLookAhead \d(?=px) - Matches a group after the main expression without including it in the result.
negativeLookAhead \d(?!px) - Specifies a group that can not match after the main expression (if it matches, the result is discarded).
positiveLookBehind (?<=ABC) - Matches a group before the main expression without including it in the result.
negativeLookBehind (?<!ABC) - Specifies a group that can not match before the main expression (if it matches, the result is discarded).
verbatimString Unescaped string literal
tab
lineFeed
verticalTab
formFeed
carriageReturn
nullCharacter

Additional custom builders

DSL What it means
word Represents an actual word. Equivalent to /(?:\w+)/
email English email
url English url
guid GUID
uuid UUID
ip4Address IPv4
ip6Address IPv6
ipAddress IPV4 or IPv6 (does not support embedded IPv4 address)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.3.6 171 5/19/2023
0.3.5 127 5/19/2023
0.3.4 139 5/19/2023
0.3.3 252 2/3/2023
0.3.2 253 2/2/2023
0.3.1 256 2/2/2023
0.3.0 258 2/2/2023
0.2.1 254 1/31/2023
0.2.0 242 1/31/2023
0.1.0 263 1/30/2023

RELEASE_NOTES.md