budul.RegexExtensions 2.0.0

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

RegexExtensions

NuGet License

Multiple extension methods to ease the determination of regex matches.

Installation

dotnet add package budul.RegexExtensions

Target framework: net10.0.

Usage

All matches are full matches: the pattern has to match the whole input. Line breaks in a pattern separate alternatives.

using RegexExtensions;

// Full match, case-insensitive by default
var isMatch = "abc".IsMatch(".{3}");                   // true
var isPartial = "abc".IsMatch(".{2}");                 // false

// Each line is an alternative
var isAlternative = "Bus B".IsMatch("Bus A\nBus B");   // true

// Build the full match pattern yourself
var pattern = new[] { "Bus A", "Bus B" }.GetFullmatchPattern();   // \A(?:Bus A|Bus B)\z

// An empty pattern means no filter
var passes = "abc".IsMatchOrEmptyPattern(null);                  // true

// An empty value or an empty pattern means no filter
var passesEmpty = ((string?)null).IsMatchOrEmptyPatternOrEmptyValue(".{2}");   // true

// Limit the duration of a match, e.g. for patterns from untrusted sources
var limited = "abc".IsMatch(".{3}", matchTimeout: TimeSpan.FromSeconds(1));    // true

Notes:

  • IsMatch returns false for an empty or whitespace-only input or pattern.
  • The default options are IgnoreCase | Multiline | CultureInvariant.
  • Lines of a pattern are not trimmed. Multi-line patterns cannot be combined with RegexOptions.IgnorePatternWhitespace.
  • An invalid pattern throws a RegexParseException, an exceeded match timeout a RegexMatchTimeoutException.
  • The regexes are cached internally per pattern, options and timeout (up to 256 entries).

Migration

1.x to 2.0

  • The package targets net10.0 only. Version 1.x stays available for netstandard2.0, netstandard2.1 and .NET Framework.
  • Nullable reference types are annotated.
  • Case-insensitive matching is culture-invariant by default.
  • The match methods accept an optional matchTimeout.

Build and test

Requires Visual Studio 2026 and the .NET 10 SDK (see global.json).

dotnet test

License

MIT, see LICENSE.

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 budul.RegexExtensions:

Package Downloads
budul.CSVReader

Deserializer for values from CSV files

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 106 11/30/2026
1.5.1 2,524 12/1/2021
1.5.0 1,246 12/1/2021
1.4.0 535 8/22/2021
1.3.0 2,341 10/11/2020
1.2.0 1,567 5/28/2020
1.1.0 681 5/5/2020
1.0.0 701 5/5/2020