Open.Text 6.3.0

.NET Standard 2.0
dotnet add package Open.Text --version 6.3.0
NuGet\Install-Package Open.Text -Version 6.3.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="Open.Text" Version="6.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Open.Text --version 6.3.0
#r "nuget: Open.Text, 6.3.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Open.Text as a Cake Addin
#addin nuget:?package=Open.Text&version=6.3.0

// Install Open.Text as a Cake Tool
#tool nuget:?package=Open.Text&version=6.3.0


A set of useful extensions for working with strings, string-segments, spans, enums, and value formatting.



  • Avoids allocation wherever possible.
  • v3.x is a major overhaul with much improved methods and expanded tests and coverage.
  • v4.x favored use of Microsoft.Extensions.Primitives.StringSegments for string manipulation.

Regex Extensions

ReadOnlySpan<char> Capture.AsSpan()
Enumerable<StringSegment> Regex.AsSegments(string input)
string GroupCollection.GetValue(string groupName)
ReadOnlySpan<char> GroupCollection.GetValueSpan(string groupName)
IEnumerable<StringSegment> string.Split(Regex pattern)

String vs Span Equality

Optimized .Equals(...) extension methods for comparing spans and strings.

String & Span Splitting


Returns each string segment of the split through an enumerable instead of all at once in an array.


Produces an enumerable where each segment is yielded as a ReadOnlyMemory<char>.


Produces an enumerable where each segment is yielded as a StringSegment.


TrimStartPattern & TrimEndPattern

Similar to their character trimming counterparts, these methods can trim sequences of characters or regular expression patterns.

StringBuilder Extensions

Extensions for:

  • adding segments with separators.
  • adding spans without creating a string first.
  • converting enumerables to a StringBuilder.

StringSegment Extensions

Extensions for:

  • .Trim(char) and .Trim(ReadOnlySpan<char>).
  • finding and pivoting from sequences without allocation.

StringComparable & SpanComparable Extensions

if(myString.AsCaseInsensitive()=="HELLO!") { }

instead of

if(myString.Equals("HELLO!", StringComparison.OrdinalIgnoreCase)) { }

EnumValue<TEnum> & EnumValueIgnoreCase<TEnum>

Implicit conversion makes it easy. Optimized methods make it fast.

Consider the following:

enum Greek { Alpha, Beta, Gamma }

void DoSomethingWithGreek(Greek value) { }


It's nice that Greek is an enum because it won't be null, and it has to be one of the values. But what if you want to write a single function that will take an Greek or a string? This gets problematic as the string value has to be parsed and you'll likely need an overload.

EnumValue<TEnum> solves this problem:

enum Greek { Alpha, Beta, Gamma }

void DoSomethingWithGreek(EnumValue<Greek> value) { }

// Both work fine.

// Throws an ArgumentException:

The implicit conversion between a string and EnumValue<TEnum> make this possible.

If you need to allow for case-insensitive comparison then simply use EnumValueCaseIgnored<TEnum> instead.

The performance is outstanding as it uses the length of the names to build a tree in order to parse values and uses an expression tree instead of calling .ToString() on the value.

And more ...


An alternative to String.Format that takes an array of values.


A shortcut for replacing whitespace with a Regex.


Returns an abbreviated metric representation of a number.


Returns an abbreviated metric representation of a quantity of bytes.


Shortcut for formating to a percent.


Allows for simple null operators if a string is empty or whitespace.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Open.Text:

Package Downloads

Useful set of collections, and extensions for collections with thread-safe read-write access options. Part of the "Open" set of libraries.


Simple set of DateTime extensions extensions. Code savers like: .Delta(time?)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
6.3.0 692 10/7/2022
6.2.1 7,334 5/20/2022
6.2.0 2,214 3/30/2022
6.1.0 245 2/25/2022
6.0.2 636 2/23/2022
6.0.1 227 2/22/2022
6.0.0 235 2/16/2022
4.2.6 221 2/16/2022
4.2.5 239 2/16/2022
4.2.4 239 2/16/2022
4.2.3 232 2/12/2022
4.2.2 278 10/28/2021
4.2.1 200 10/28/2021
4.2.0 209 10/28/2021
4.1.1 228 10/25/2021
4.1.0 199 10/19/2021
4.0.1 203 10/18/2021
3.6.3 318 10/17/2021
3.5.0 218 10/15/2021
3.4.3 252 10/11/2021
3.4.2 374 9/20/2021
2.1.0 716 7/3/2019
2.0.5 654 6/30/2019
2.0.4 701 3/31/2019
1.1.0 9,450 1/4/2018