MyStringExtensions 2.0.0

dotnet add package MyStringExtensions --version 2.0.0
                    
NuGet\Install-Package MyStringExtensions -Version 2.0.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="MyStringExtensions" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyStringExtensions" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MyStringExtensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyStringExtensions --version 2.0.0
                    
#r "nuget: MyStringExtensions, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MyStringExtensions@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyStringExtensions&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MyStringExtensions&version=2.0.0
                    
Install as a Cake Tool

My String Extensions

The most used string algorithms gathered under a single class

Install

NuGet\Install-Package MyStringExtensions -Version 1.0.0

version of package for use last version see https://www.nuget.org/packages/MyStringExtensions/

How to use

<code>Cut(length)</code> Substring for unknown length. No errors for mismatches due to empty space or lengthSubstring for unknown length. No errors for mismatches due to empty space or length

string sourceText = "++a little Bunny raBBit waNdering in a huge Forest";
string nullText = null;

Console.WriteLine(nullText.Cut(22));
//Output: ""

//----------------------------------

Console.WriteLine(sourceText.Cut(5));
//Output: "++a l"

<code>TrimInside()</code> Trim all whitespace in text

Console.WriteLine(sourceText.TrimInside());
//Output: "++alittleBunnyraBBitwaNderinginahugeForest"

<code>NullExists()</code> Check Null or Empty value in string collection

var nulls = new List<string> { "t1", null, "t2" };
Console.WriteLine(nulls.NullExists());
//Output: "True"

//----------------------------------

nulls = new List<string> { "t1", "t2", "t3" };
Console.WriteLine(nulls.NullExists());
//Output: "False"

<code>ContainsNosense(seek)</code> Find a word in string without sensivity

Console.WriteLine(sourceText.ContainsNosense("rabbit"));
//Output: "True"

//----------------------------------

Console.WriteLine(sourceText.ContainsNosense("horse"));
//Output: "False"

<code>CountWords(seek)</code> Find how many times the word you are looking for is repeated in the text

Console.WriteLine(sourceText.CountWords("rabbit"));
//Output: 1

//----------------------------------
Console.WriteLine(sourceText.CountWords("horse"));
//Output: 0

<code>RandomString(length)</code> Generate Random text

Console.WriteLine(StringExtensions.RandomString(12));
//Output: "%0n9jdhwENCv"

<code>EncryptHash()</code> Generate non-recyclable writing from your text

Console.WriteLine(sourceText.EncryptHash());
//Output: "9bbdadb281d35bfd90270a06abe0f12ec061957f38a36d8aceefb95630cac6d1"

<code>Mask(start, length)</code> Generate masked text from your text

Console.WriteLine(sourceText.Mask(8,12));
//Output: "++a littl***********Bit waNdering in a huge Forest"

<code>Mask(startLength, maskLength, endLength, maskChar='*')</code> Generate masked text from your text

Console.WriteLine("HelloWorld!".Mask(4,2, 2, 'x'));
//Helloxxld!

<code>ToImage()</code> Text to image bytes. Exports png file bytes. Only works on Windows OS

var imgBytes = sourceText.ToImage();
File.WriteAllBytes("img.png", imgBytes);
//Output: "img file"

<code>ForWordsIn(seek, act)</code> Run a delegated action for each found word. Detailed

sourceText.ForWordsIn("i", x => Console.WriteLine(x));
//Output:
    //"little
    //"raBBit"
    //"waNdering"
    //"in"

<code>ToTitleCase()</code> Make uppercase the first letters after a space

Console.WriteLine(sourceText.ToTitleCase());
//Output: "++A Little Bunny Rabbit Wandering In A Huge Forest"

<code>ToBodyCase()</code> Make uppercase the first character of the text

Console.WriteLine(sourceText.ToBodyCase());
//Output: "++A little Bunny raBBit waNdering in a huge Forest"

<code>ToLowerUnderscored()</code> Make snakecase for source text

Console.WriteLine(sourceText.ToLowerUnderscored());
//Output: "++a_little_bunny_ra_b_bit_wa_ndering_in_a_huge_forest"

<code>Singularize()</code> Deduplicate characters that repeat side by side

Console.WriteLine(sourceText.Singularize());
//Output: "+a litle Buny raBit waNdering in a huge Forest"

<code>Multiplex(length)</code> Duplicate a selected text as many times as you like

Console.WriteLine("#".Multiplex(21));
//Output: "######################"


<code>LoopIn(func)</code> Run an action for each character in the text

var result = sourceText.LoopIn(x => {
    if (x.Equals('h')) {
        return true;
    }
    return false;
});
Console.WriteLine(result);
//Output: True

<code>ClearDigits()</code> Remove numeric chars and return new string object

Console.WriteLine("123 ankara ++".ClearDigits());
//Output: "ankara ++"

<code>ClearSymbols()</code> Remove symbolic chars and return new string object

Console.WriteLine(sourceText.ClearSymbols());
//Output: "a little Bunny raBBit waNdering in a huge Forest"

<code>ClearDigits() + ClearSymbols() + TrimInside()</code>

Console.WriteLine("123 ankara ++ merkez".ClearDigits().ClearSymbols().TrimInside());
//Output: "ankaramerkez"

<code>Compress()</code> Compress text size

string gg = "Kediler, ba��ms�z ve merakl� yap�lar�yla bilinen evcil hayvanlard�r. �e�itli boyut ve renklerde olmalar�na ra�men ortak baz� �zellikleri vard�r. Ok�and�klar�nda m�r�ldanmalar�, avlanma i�g�d�lerinin g��l� olmas� ve y�ksek yerlere t�rmanmaktan ho�lanmalar� kedilerin dikkat �ekici �zelliklerindendir. Baz� insanlar kedileri yaln�z ve mesafeli bulurken, di�erleri onlar�n sevgi dolu ve sad�k arkada�lar oldu�unu d���n�r. Tarih boyunca insanlarla birlikte ya�ayan kediler, hem evlerde hem de sokaklarda ya�am�n� s�rd�rebilirler.";
Console.WriteLine("Compressed Text      : " + gg);
Console.WriteLine();
Console.WriteLine("Compressed Size      : " + gg.Compress().Length);
Console.WriteLine("Decompressed Size    : " + Encoding.ASCII.GetBytes(gg).Length);

//Compressed Text      : Kediler, ba��ms�z ve merakl� yap�lar�yla bilinen evcil hayvanlard�r. �e�itli boyut ve renklerde olmalar�na ra�men ortak baz� �zellikleri vard�r. Ok�and�klar�nda m�r�ldanmalar�, avlanma i�g�d�lerinin g��l� olmas� ve y�ksek yerlere t�rmanmaktan ho�lanmalar� kedilerin dikkat �ekici �zelliklerindendir. Baz� insanlar kedileri yaln�z ve mesafeli bulurken, di�erleri onlar�n sevgi dolu ve sad�k arkada�lar oldu�unu d���n�r. Tarih boyunca insanlarla birlikte ya�ayan kediler, hem evlerde hem de sokaklarda ya�am�n� s�rd�rebilirler.
//Compressed Size      : 460
//Decompressed Size    : 525

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.0.0 147 8/1/2024
1.0.0 280 9/16/2023