Asal.StringExtentions 1.7.0

dotnet add package Asal.StringExtentions --version 1.7.0
                    
NuGet\Install-Package Asal.StringExtentions -Version 1.7.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="Asal.StringExtentions" Version="1.7.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asal.StringExtentions" Version="1.7.0" />
                    
Directory.Packages.props
<PackageReference Include="Asal.StringExtentions" />
                    
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 Asal.StringExtentions --version 1.7.0
                    
#r "nuget: Asal.StringExtentions, 1.7.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 Asal.StringExtentions@1.7.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=Asal.StringExtentions&version=1.7.0
                    
Install as a Cake Addin
#tool nuget:?package=Asal.StringExtentions&version=1.7.0
                    
Install as a Cake Tool

Asal.StringExtentions

A lightweight .NET utility library that provides powerful string extensions and serialization helpers to simplify common development tasks.


📦 Installation

Using .NET CLI

dotnet add package Asal.StringExtentions

Using Package Manager Console

Install-Package Asal.StringExtentions

Using Visual Studio

  1. Open Manage NuGet Packages
  2. Search for Asal.StringExtentions
  3. Click Install

🚀 Usage

After installing the package, import the namespace and call extensions directly on strings:

using Asal.StringExtentions;

var result = "Hello@World!".ClearSpecialCharacters();

✨ Available Extensions

🔤 String Utilities

1. ClearSpecialCharacters(bool replaceWithSpace = false)

Removes special characters from the string.

"Hello@World!".ClearSpecialCharacters(); 
// Output: "HelloWorld"

2. ClearDigits(bool replaceWithSpace = false)

Removes all digits from the string.

"abc123".ClearDigits(); 
// Output: "abc"

3. Humanize()

Separates PascalCase or camelCase words.

"HelloWorldTest".Humanize(); 
// Output: "Hello World Test"

4. IsValidEmail()

Checks if the string is a valid email address.

"test@mail.com".IsValidEmail(); // true

5. ExtractEmails()

Extracts all valid emails from a string.

var text = "Contact admin@test.com or support@domain.com";
var emails = text.ExtractEmails();

📄 JSON Extensions

6. ExtractJsonPropertyValue(string jsonProperty)

Extracts a property value from a JSON string using path syntax.

var json = "{\"name\":\"John\",\"age\":30}";
var result = json.ExtractJsonPropertyValue<string>("name");
// Output: "John"

Nested example:

var json = "{\"data\":[{\"baseObject\":{\"name\":\"test\",\"age\":25}}]}";
var age = json.ExtractJsonPropertyValue<int>("data[0].baseObject.age");
// Output: 25

Extract object:

var obj = json.ExtractJsonPropertyValue<object>("data[0].baseObject");

7. TryExtractJsonPropertyValue(string jsonProperty, out T result)

Safe extraction without throwing exceptions.

var success = json.TryExtractJsonPropertyValue<int>("data[0].baseObject.age", out var age);
// success = true, age = 25

8. ExtractJsonArrayPropertyValue(string jsonProperty)

Extracts array values as IEnumerable<T>.

var json = "{\"cars\":[\"Ford\",\"BMW\",\"Fiat\"]}";
var cars = json.ExtractJsonArrayPropertyValue<string>("cars");
// ["Ford", "BMW", "Fiat"]

Supports:

  • Primitive arrays
  • Nested arrays
  • JSONPath style queries (items[*].id)

🔄 XML / JSON / YAML Converters

9. XmlToJson()

Converts XML string to JSON.

var xml = "<root><name>Hamza</name></root>";
var json = xml.XmlToJson();

10. JsonToXml()

Converts JSON string to XML.

⚠️ Behavior Change (v1.7.0)

JsonToXml() no longer wraps the output automatically with a default <root> element.

If JSON already contains a root:

var json = "{\"root\":{\"name\":\"Hamza\"}}";
var xml = json.JsonToXml(); // Correct round-trip

If JSON has no root:

var json = "{\"name\":\"Hamza\"}";
var xml = json.JsonToXml("root"); // Explicit wrapping

Parameters:

  • deserializeRootElementName (optional)
  • writeArrayAttribute (default: false)
  • encodeSpecialCharacters (default: false)

11. YamlToJson()

Converts YAML string to JSON.

var yaml = "Id: 1\nName: Test";
var json = yaml.YamlToJson();

12. JsonToYaml()

Converts JSON string to YAML.

var yaml = json.JsonToYaml();

🧩 Case Conversion Extensions

13. Slugify()

Creates SEO-friendly slugs.

"Café Déjà Vu Example".Slugify();
// "cafe-deja-vu-example"

14. ToCamelCase()

"hello world".ToCamelCase(); // "helloWorld"

15. ToPascalCase()

"hello world".ToPascalCase(); // "HelloWorld"

16. ToSnakeCase()

"hello world".ToSnakeCase(); // "hello_world"

17. ToKebabCase()

"hello world".ToKebabCase(); // "hello-world"

🔐 Security Utility

18. CalculateMD5Checksum()

Generates an MD5 hash for the input string.

var checksum = "hello world".CalculateMD5Checksum();
// "5eb63bbbe01eeed093cb22bb8f5acdc3"

⚡ Improvements in v1.7.0

  • Centralized compiled Regex patterns (better performance)
  • Improved JSON array extraction (supports primitives & complex objects)
  • Nullable safety and reliability improvements
  • Cleaner and optimized internal implementation

📊 Milestone

🎉 Over 4,500+ downloads on NuGet!

Thank you for your support 🙏

Product 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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.7.0 123 2/18/2026
1.6.1 235 4/15/2024
1.6.0 185 4/15/2024
1.5.4 309 5/26/2023
1.5.0 250 5/24/2023
1.4.0 247 5/1/2023
1.3.0 288 4/16/2023
1.2.1 339 3/29/2023
1.1.0 324 3/29/2023
1.0.3 335 3/15/2023
1.0.2 344 3/15/2023
1.0.1 345 3/14/2023
1.0.0 323 3/14/2023

Improvements and behavioral adjustments:
     - Introduced centralized compiled RegexPatterns for better performance
     - Improved JSON array extraction to support both primitive and object tokens
     - Fixed nullable warnings in JSON helper methods
     - Code cleanup and reliability improvements

     Behavioral Change:
     - JsonToXml() no longer wraps the result in a default root element automatically.
     Pass a root name explicitly if wrapping is required.