Sprocket.Text.Explode 1.0.0

.NET 5.0
Install-Package Sprocket.Text.Explode -Version 1.0.0
dotnet add package Sprocket.Text.Explode --version 1.0.0
<PackageReference Include="Sprocket.Text.Explode" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sprocket.Text.Explode --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Sprocket.Text.Explode, 1.0.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 Sprocket.Text.Explode as a Cake Addin
#addin nuget:?package=Sprocket.Text.Explode&version=1.0.0

// Install Sprocket.Text.Explode as a Cake Tool
#tool nuget:?package=Sprocket.Text.Explode&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Created by David Pullin

Readme Last Updated on 12.02.2021

The full API can be found at https://ict-man.me/sprocket/api/Sprocket.Text.Explode.html

Licence GPL-3.0 License

Source code is hosted on GitHub here: https://github.com/david-pullin/ascii-calendar

Summary

Explode provides an extension function to the String class to split strings via a specified character or string. Useful for processing Comma Delimited (CSV) content.

Support is provided for text delimiters, for example, file that make use of the " character enclose strings that contain the field separator.

Examples

Namespace: Sprocket.Text.Explode

Example with default field delimiters

string s = "one,\"two.1,two.2\",three";

var sr = s.Explode(new ExplodeOptions());
List<string> sl = sr.Cells.ToStringList();

Assert.Equal(3, sl.Count);
Assert.Equal("one", sl[0]);
Assert.Equal("two.1,two.2", sl[1]);
Assert.Equal("three", sl[2]);

Example with a multiple character field delimiter

string s = "one_x_two_x_three";

var delim = new Delimiters("_x_");
var opts = new ExplodeOptions();
opts.Delimiters = delim;
var sr = s.Explode(opts);
List<string> sl = sr.Cells.ToStringList();

Assert.Equal(3, sl.Count);
Assert.Equal("one", sl[0]);
Assert.Equal("two", sl[1]);
Assert.Equal("three", sl[2]);

Note: The full API can be found at https://ict-man.me/sprocket/api/Sprocket.Text.Explode.html


ExplodeOptions Class

Namespace: Sprocket.Text.Explode

Properties

Name Type Default Summary
EnableTextDelimiter bool true Enables the processing of Text Delimiters. When enabled, Explode will process instances of the specified Delimiters.TextDelimiter to signify that any enclosed Delimiters.FieldDelimiter are taken as content.
StrictTextDelimiterPositioning bool true When enabled it is expected that the Delimiters.TextDelimiter (if present), it is positioned at then beginning and end of each field. If disabled, any Delimiters.TextDelimiter will be processed as a delimiter regardless of its position.
StrictTextDelimiterPositioning AllowLeadingTrailingSpaces bool true When enabled will allow for leading and trailing spaces before and after the Text Delimiters.
AllowInsideDoubleTextDelimiters bool true When enabled, and when containted within text delimiters, allows for double instances of the Delimiters.TextDelimiter to be processed as single instance content.
Delimiters Delimiters , and " Which character or strings are being used for Field and Text Delimiters.
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
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 169 2/12/2021