Open.Text
8.2.1
See the version list below for details.
dotnet add package Open.Text --version 8.2.1
NuGet\Install-Package Open.Text -Version 8.2.1
<PackageReference Include="Open.Text" Version="8.2.1" />
paket add Open.Text --version 8.2.1
#r "nuget: Open.Text, 8.2.1"
// Install Open.Text as a Cake Addin #addin nuget:?package=Open.Text&version=8.2.1 // Install Open.Text as a Cake Tool #tool nuget:?package=Open.Text&version=8.2.1
Open.Text
A set of useful extensions for working with strings, string-segments, spans, enums, and value formatting.
Features
- 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
SplitToEnumerable
Returns each string segment of the split through an enumerable instead of all at once in an array.
SplitAsMemory
Produces an enumerable where each segment is yielded as a ReadOnlyMemory<char>
.
SplitAsSegment
Produces an enumerable where each segment is yielded as a StringSegment
.
Trimming
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) { }
DoSomethingWithGreek(Greek.Alpha);
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.
DoSomethingWithGreek("Alpha");
DoSomethingWithGreek(Greek.Alpha);
// Throws an ArgumentException:
DoSomethingWithGreek("Theta");
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 ...
string.Supplant(...)
An alternative to String.Format that takes an array of values.
string.ReplaceWhiteSpace(...)
A shortcut for replacing whitespace with a Regex.
string.ToMetricString(...)
Returns an abbreviated metric representation of a number.
ToByteString(...)
Returns an abbreviated metric representation of a quantity of bytes.
ToPercentString(...)
Shortcut for formating to a percent.
ToNullIfWhiteSpace()
Allows for simple null operators if a string is empty or whitespace.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 is compatible. 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 is compatible. |
.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. |
-
.NETStandard 2.0
- Microsoft.Extensions.Primitives (>= 7.0.0)
-
.NETStandard 2.1
- Microsoft.Extensions.Primitives (>= 7.0.0)
-
net6.0
- Microsoft.Extensions.Primitives (>= 7.0.0)
-
net7.0
- Microsoft.Extensions.Primitives (>= 7.0.0)
-
net8.0
- Microsoft.Extensions.Primitives (>= 7.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Open.Text:
Package | Downloads |
---|---|
Open.Collections
Useful set of collections, and extensions for collections with thread-safe read-write access options. Part of the "Open" set of libraries. |
|
Open.DateTime.Extensions
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 |
---|---|---|
9.0.0 | 1,355 | 11/16/2024 |
8.2.1 | 118 | 11/16/2024 |
8.2.0 | 85 | 11/16/2024 |
8.1.0 | 1,611 | 8/28/2024 |
8.0.0 | 2,357 | 7/28/2024 |
7.0.3 | 2,813 | 7/12/2024 |
7.0.2 | 93 | 7/12/2024 |
7.0.1 | 264 | 6/26/2024 |
7.0.0 | 2,275 | 2/24/2024 |
7.0.0-beta | 101 | 2/24/2024 |
6.7.0 | 2,422 | 11/8/2023 |
6.6.4 | 2,719 | 6/12/2023 |
6.6.3 | 179 | 6/2/2023 |
6.6.2 | 3,749 | 5/5/2023 |
6.6.1 | 180 | 5/4/2023 |
6.6.0 | 208 | 4/29/2023 |
6.5.4 | 205 | 4/29/2023 |
6.5.2 | 540 | 3/31/2023 |
6.5.1 | 229 | 3/31/2023 |
6.5.0 | 212 | 3/31/2023 |
6.4.1 | 3,066 | 3/23/2023 |
6.4.0 | 255 | 3/13/2023 |
6.3.0 | 1,208 | 10/7/2022 |
6.2.1 | 30,836 | 5/20/2022 |
6.2.0 | 3,778 | 3/30/2022 |
6.1.0 | 466 | 2/25/2022 |
6.0.2 | 1,847 | 2/23/2022 |
6.0.1 | 434 | 2/22/2022 |
6.0.0 | 453 | 2/16/2022 |
4.2.6 | 463 | 2/16/2022 |
4.2.5 | 446 | 2/16/2022 |
4.2.4 | 446 | 2/16/2022 |
4.2.3 | 457 | 2/12/2022 |
4.2.2 | 386 | 10/28/2021 |
4.2.1 | 331 | 10/28/2021 |
4.2.0 | 339 | 10/28/2021 |
4.1.1 | 370 | 10/25/2021 |
4.1.0 | 337 | 10/19/2021 |
4.0.1 | 336 | 10/18/2021 |
3.6.3 | 478 | 10/17/2021 |
3.5.0 | 371 | 10/15/2021 |
3.4.3 | 391 | 10/11/2021 |
3.4.2 | 581 | 9/20/2021 |
2.1.0 | 954 | 7/3/2019 |
2.0.5 | 897 | 6/30/2019 |
2.0.4 | 927 | 3/31/2019 |
1.1.0 | 11,224 | 1/4/2018 |