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
<PackageReference Include="Soenneker.Utils.RegexCollection" Version="4.0.94" />
<PackageVersion Include="Soenneker.Utils.RegexCollection" Version="4.0.94" />
<PackageReference Include="Soenneker.Utils.RegexCollection" />
paket add Soenneker.Utils.RegexCollection --version 4.0.94
#r "nuget: Soenneker.Utils.RegexCollection, 4.0.94"
#:package Soenneker.Utils.RegexCollection@4.0.94
#addin nuget:?package=Soenneker.Utils.RegexCollection&version=4.0.94
#tool nuget:?package=Soenneker.Utils.RegexCollection&version=4.0.94
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\swhitespace character at a time, including tabs and line breaks—not only ASCII spaces.AlphaNumericAndDashUnderscore()matches characters outside lowercase ASCIIa-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 withhttp://,https://, orwww.and continues until whitespace or a square bracket. It is an extractor, not full URI validation.UriLastSegment()requires an absolutescheme://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 | Versions 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. |
-
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 |
Define regex collection behavior and character set