StringExtensionsNetStdIeb 1.0.0

A range of general string extensions for C#

Install-Package StringExtensionsNetStdIeb -Version 1.0.0
dotnet add package StringExtensionsNetStdIeb --version 1.0.0
<PackageReference Include="StringExtensionsNetStdIeb" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StringExtensionsNetStdIeb --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

String_Extensions

A big pile of string manipulation methods for C#, to fill in some of the gaps of the default string library.

Comparison

CompareWildcard

Match strings to patterns using * and ? placeholders. For when Regex is too much.

NaturalComparer

A comparer for use in Linq Sort(...) that respects numerical ordering.

You can drop this anywhere an IComparer is used on strings. To sort files by name with numbers in the right place:
new DirectoryInfo(@&quot;C:\temp&quot;).GetFiles().Select(f=&gt;f.Name).ToList().Sort(new NaturalComparer());
Then, given these files (as ordered by default .Net sort)

File 10, File 11, File 8, File 9

Will be sorted correctly, as would be expected:

File 8, File 9, File 10, File 11

Parsing

ToByteArray

Convert hex strings to byte arrays.

Take a string like BADF00BA into a byte array. String length should be a multiple of two.

Replacement

ReplaceCaseInvariant

Replace string fragments using a case-insensitive search.

Matching is case invariant, replacement is done preserving case.
For example: &quot;OnCe UpOn A tImE&quot;.ReplaceCaseInvariant(&quot;TiMe&quot;, &quot;Moon&quot;) == &quot;OnCe UpOn A Moon&quot;

ReplaceAsciiCompatible

Replace latin-like letters and numbers with their ASCII equivalents.

This will replace accented forms with ones that look similar, but it
will often destroy or change meaning. Do NOT use this to present output
to users. It is intended to use for stored search targets.
This is not exhaustive, and does not handle characters that are not latin-like (e.g. CJK)

H&#201;LLO, &#197;bj&#248;rn!&quot;.ReplaceAsciiCompatible() == &quot;HELLO, Abjorn!&quot;

Searching

FindCluster

A very simple O(n+m) algorithm for finding clusters of characters in a string.
(i.e. it will find wxyz in abc zwyx abc, but not in ab xy ab wz)

This algorithm will give some false positives where the sum of character values match.

Substrings

A range of substring before/after first/last instances of a character or string.

SubstringBefore, SubstringBeforeLast, SubstringAfter, ExtendedIndexOf, SubstringAfterLast

String_Extensions

A big pile of string manipulation methods for C#, to fill in some of the gaps of the default string library.

Comparison

CompareWildcard

Match strings to patterns using * and ? placeholders. For when Regex is too much.

NaturalComparer

A comparer for use in Linq Sort(...) that respects numerical ordering.

You can drop this anywhere an IComparer is used on strings. To sort files by name with numbers in the right place:
new DirectoryInfo(@&quot;C:\temp&quot;).GetFiles().Select(f=&gt;f.Name).ToList().Sort(new NaturalComparer());
Then, given these files (as ordered by default .Net sort)

File 10, File 11, File 8, File 9

Will be sorted correctly, as would be expected:

File 8, File 9, File 10, File 11

Parsing

ToByteArray

Convert hex strings to byte arrays.

Take a string like BADF00BA into a byte array. String length should be a multiple of two.

Replacement

ReplaceCaseInvariant

Replace string fragments using a case-insensitive search.

Matching is case invariant, replacement is done preserving case.
For example: &quot;OnCe UpOn A tImE&quot;.ReplaceCaseInvariant(&quot;TiMe&quot;, &quot;Moon&quot;) == &quot;OnCe UpOn A Moon&quot;

ReplaceAsciiCompatible

Replace latin-like letters and numbers with their ASCII equivalents.

This will replace accented forms with ones that look similar, but it
will often destroy or change meaning. Do NOT use this to present output
to users. It is intended to use for stored search targets.
This is not exhaustive, and does not handle characters that are not latin-like (e.g. CJK)

H&#201;LLO, &#197;bj&#248;rn!&quot;.ReplaceAsciiCompatible() == &quot;HELLO, Abjorn!&quot;

Searching

FindCluster

A very simple O(n+m) algorithm for finding clusters of characters in a string.
(i.e. it will find wxyz in abc zwyx abc, but not in ab xy ab wz)

This algorithm will give some false positives where the sum of character values match.

Substrings

A range of substring before/after first/last instances of a character or string.

SubstringBefore, SubstringBeforeLast, SubstringAfter, ExtendedIndexOf, SubstringAfterLast

  • .NETStandard 1.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 History

Version Downloads Last updated
1.0.0 67 8/21/2020