You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

NorthSouthSystems.Text

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

NorthSouthSystems.Text

This .NET library contains string utilities including fluent APIs for splitting and joining quoted delimited text (e.g. CSV used by Microsoft Excel) and fixed-width positional text.

4.3.9
nugetNuGet
Version published
Maintainers
1
Created
Source

NorthSouthSystems.Text

This .NET library contains string utilities including fluent APIs for splitting and joining quoted delimited text (e.g. CSV used by Microsoft Excel) and fixed-width positional text.

Quoted Delimited Text (e.g. CSV used by Microsoft Excel) Splitting and Joining

Simple Split

string row = "a,b,c";
string[]() fields = row.SplitQuotedRow(StringQuotedSignals.CsvNewRowTolerantWindowsPrimaryRFC4180);

foreach(string field in fields);
    Console.WriteLine(field);
Console Output:
a
b
c

Simple Join

string[]()() fields = new string[]()() { "a", "b", "c" };
string result = fields.JoinQuotedRow(StringQuotedSignals.CsvNewRowTolerantWindowsPrimaryRFC4180);
Console.WriteLine(result);
Console Output:
a,b,c

Quoted Split

var signals = new StringQuotedSignalsBuilder()
    .Delimiter(",")
    .NewRowTolerantEnvironmentPrimary()
    .Quote("'")
    .ToSignals();
string row = "'a,a',b,c";
string[]() fields = row.SplitQuotedRow(signals);

foreach(string field in fields);
    Console.WriteLine(field);
Console Output:
a,a
b
c

Quoted Join

string[]()() fields = new string[]()() { "a,a", "b", "c" };
string result = fields.JoinQuotedRow(StringQuotedSignals.CsvNewRowTolerantWindowsPrimaryRFC4180);
Console.WriteLine(result);
Console Output:
"a,a",b,c

Fixed-Width (a.k.a. Positional) Text Splitting and Joining

Split

string row = "A-B-C";
string[]()() fields = row.SplitFixedRow(new []()() { 2, 2, 1 });

foreach(string field in fields)
    Console.WriteLine(field);

fields = row.SplitFixedRow(new []() { 2, 2, 1 }, '-');

foreach(string field in fields)
    Console.WriteLine(field);
Console Output:
A-
B-
C
A
B
C

Join

string fields = new []() { "A", "B", "C" };
string row = fields.JoinFixedRow(new []() { 2, 2, 1 });
Console.WriteLine(row);

row = fields.JoinFixedRow(new []() { 2, 2, 1 }, '-', false);
Console.WriteLine(row);
Console Output:
A B C
A-B-C

Schema Fixed-Width (a.k.a. Positional) Text Splitting and Joining

Split

var schema = new StringSchema();
schema.AddEntry(new StringSchemaEntry("A", new[]() { 1, 1, 1 }));
schema.AddEntry(new StringSchemaEntry("B", new[]() { 2, 2, 2 }));
schema.AddEntry(new StringSchemaEntry("CD", new[]() { 3, 3, 3 }));

var split = "A123".SplitSchemaRow(schema);
Console.WriteLine(split.Entry.Header);

foreach(StringFieldWrapper field in split.Result.Fields)
    Console.WriteLine(field);

split = "B123456".SplitSchemaRow(schema);
Console.WriteLine(split.Entry.Header);

foreach(StringFieldWrapper field in split.Result.Fields)
    Console.WriteLine(field);

split = "CD123456789".SplitSchemaRow(schema);
Console.WriteLine(split.Entry.Header);

foreach(StringFieldWrapper field in split.Result.Fields)
    Console.WriteLine(field);
Console Output:
A
1
2
3
B
12
34
56
CD
123
456
789

Join

var a = new StringSchemaEntry("A", new[]() { 1, 1, 1 });
var b = new StringSchemaEntry("B", new[]() { 2, 2, 2 });
var c = new StringSchemaEntry("C", new[]() { 2, 2, 2 }, '-');

string[]()() fields = new[]()() { "1", "2", "3" };
string join = fields.JoinSchemaRow(a);
Console.WriteLine(join);

fields = new[]() { "12", "34", "56" };
join = fields.JoinSchemaRow(b);
Console.WriteLine(join);

fields = new[]() { "1", "2", "3" };
join = fields.JoinSchemaRow(c);
Console.WriteLine(join);
Console Output:
A123
B123456
C1-2-3-

Other String Utilities

NormalizeWhiteSpace

Console.WriteLine(" A  B C   D   ".NormalizeWhiteSpace());
Console.WriteLine(("Lots\tOf" + Environment.NewLine + "Changes").NormalizeWhiteSpace());
Console Output:
A B C D
Lots Of
Changes

SpaceCamelCase

Console.WriteLine("FooBarFoo FooBarFoo".SpaceCamelCase());
Console.WriteLine("123A".SpaceCamelCase());
Console.WriteLine("123a".SpaceCamelCase());
Console.WriteLine("A123".SpaceCamelCase());
Console.WriteLine("A123A".SpaceCamelCase());
Console Output:
Foo Bar Foo Foo Bar Foo
123 A
123 a
A 123
A 123 A

ToLowerCamelCase

Console.WriteLine("FooBar".ToLowerCamelCase());
Console Output:
fooBar

ToUpperCamelCase

Console.WriteLine("fooBar".ToUpperCamelCase());
Console Output:
FooBar

WhereIsInAnyCategory

Console.WriteLine("a1b2c3d".WhereIsInAnyCategory(CharCategories.All));
Console.WriteLine("a1b2c3d".WhereIsInAnyCategory(CharCategories.Digit));
Console.WriteLine("a1b2c3d".WhereIsInAnyCategory(CharCategories.Punctuation | CharCategories.WhiteSpace));
Console.WriteLine("a1b2-c3d".WhereIsInAnyCategory(CharCategories.Digit | CharCategories.Letter));
Console.WriteLine("a1b2-c3d".WhereIsInAnyCategory(CharCategories.Punctuation));
Console Output:
a1b2c3d
123

a1b2c3d
-

Keywords

FAQs

Package last updated on 02 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts