Soenneker.Utils.RegexCollection 4.0.94

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.RegexCollection

A collection of regular expressions that are generated at compile time

Installation

dotnet add package Soenneker.Utils.RegexCollection

Usage

using Soenneker.Utils.RegexCollection;

string spacesToDashes = RegexCollection.Spaces().Replace("hello there", "-");
// "hello-there"

The methods return source-generated Regex instances and are safe to reuse across calls and threads. They do not use runtime pattern compilation.

Available patterns

Text cleanup

  • Spaces() matches one .NET \s whitespace character at a time, including tabs and line breaks—not only ASCII spaces.
  • AlphaNumericAndDashUnderscore() matches characters outside lowercase ASCII a-z, digits, whitespace, _, and -. Uppercase letters are removed unless the caller normalizes case first.
  • DoubleOccurrencesOfDashUnderscore() matches a run of two or more dash/underscore characters, including mixed runs such as -_.
string slug = input.ToLowerInvariant();
slug = RegexCollection.AlphaNumericAndDashUnderscore().Replace(slug, "");
slug = RegexCollection.Spaces().Replace(slug, "-");
slug = RegexCollection.DoubleOccurrencesOfDashUnderscore().Replace(slug, "-");

URLs and hostnames

  • Url() finds text beginning with http://, https://, or www. and continues until whitespace or a square bracket. It is an extractor, not full URI validation.
  • UriLastSegment() requires an absolute scheme:// form with a non-empty final path segment. Group 1 contains the URI prefix before that segment, group 2 the slash and final segment, and group 3 the remaining query/fragment text.
  • DnsHostname() validates a multi-label ASCII hostname with an alphabetic TLD of at least two letters. It rejects single-label hosts, a trailing root dot, underscores, Unicode IDNs, and punycode TLDs containing hyphens.

Use Uri.TryCreate, IdnMapping, or a DNS-aware validator when those broader semantics are needed.

Structured text

  • Spintax() matches {{ RANDOM | ... }} and captures all option text in group 1; it does not split options or choose one.
  • CityStatePostal() captures city, two-letter state text, and a US five-digit or ZIP+4 value in groups 1–3. It checks shape only, not whether the city, state, or ZIP exists.
  • MarkdownCodeFence() matches an opening triple-backtick fence only at the beginning of the entire input. Its optional language identifier accepts ASCII letters only, and trailing \s* can consume whitespace following the fence.

None of these patterns sanitize untrusted input for HTML, SQL, shell commands, filesystem paths, or network access. Apply validation and encoding appropriate to the eventual sink.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Utils.RegexCollection:

Package Downloads
Soenneker.Utils.String

A utility library for useful String operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.94 1,022 8/30/2026
4.0.93 6,087 7/27/2026
4.0.92 2,839 7/16/2026
4.0.91 4,939 6/18/2026
4.0.89 6,120 4/23/2026
4.0.84 4,437 3/10/2026
4.0.83 452 3/9/2026
4.0.82 195 3/9/2026
4.0.81 1,685 3/4/2026
4.0.80 295,142 1/2/2026
4.0.79 205,775 11/20/2025
4.0.78 110,665 10/29/2025
3.0.77 230,451 9/3/2025
3.0.76 96,905 8/11/2025
3.0.74 278,171 5/27/2025
3.0.73 30,355 5/25/2025
3.0.72 20,932 5/22/2025
3.0.71 74,659 5/7/2025
3.0.70 34,739 5/5/2025
3.0.69 8,526 5/5/2025
Loading failed

Define regex collection behavior and character set