This package provides utility extension methods for advanced string manipulation in .NET applications.
$ dotnet add package Easy.Tools.StringHelpersEasy.Tools.StringHelpers is a high-performance, secure, and enterprise-ready .NET library providing a rich set of string extension methods. It is re-engineered with Zero-Allocation techniques for modern .NET, ReDoS protection for Regex operations, and strictly typed validation helpers.
Span<T>, string.Create, and ValueTuple on modern frameworks (.NET 6+) to minimize memory pressure..NET 10, .NET 9, .NET 8, .NET 6, .NET Standard 2.0/2.1, and .NET Framework 4.7.2+.Install via NuGet Package Manager:
Install-Package Easy.Tools.StringHelpers
Or via .NET CLI:
dotnet add package Easy.Tools.StringHelpers
Validate inputs without throwing unnecessary exceptions.
using Easy.Tools.StringHelpers.Extensions;
// Email & Password Validation
if (userInput.IsValidEmail() && password.IsValidPassword(minLength: 10, requireSpecialChar: true))
{
// Proceed safely...
}
// Credit Card Validation (Luhn Algorithm - Zero Allocation)
if (creditCardString.IsValidCreditCard())
{
// Payment logic...
}
// JSON Structure Check
bool isJson = apiResponse.IsValidJson();
Perform string operations with minimal memory footprint.
string title = " High Performance Code ";
// Slug generation (Supports Turkish characters: ı->i, ğ->g)
string slug = title.GenerateSlug(); // "high-performance-code"
string description = "This is a very long text that needs to be shortened.";
// Truncate using Span<T> optimizations
string preview = description.Truncate(20, addEllipsis: true); // "This is a very lo..."
Securely handle sensitive data.
string email = "admin@example.com";
Console.WriteLine(email.MaskEmail()); // "ad***@example.com"
// Secure Random Password (CSPRNG)
string secret = GenerationExtensions.RandomPassword(16);
| Category | Description |
|---|---|
ValidationExtensions | Validate Email, Credit Card (Luhn), JSON, XML, URL, IP, Palindrome, etc. |
SanitizeExtensions | High-perf removal of HTML tags, special chars, digits (Loop-based). |
TruncateExtensions | Smart string truncation with ellipsis support (Zero-alloc). |
ManipulationExtensions | General manipulation: RemoveWhitespace, SplitLines, Repeat, NormalizeSpaces. |
MaskingExtensions | Mask sensitive data like Emails or IDs. |
SearchExtensions | ContainsAny, ContainsAll, CountOccurrences, IsNumeric. |
TransformationExtensions | GenerateSlug (Turkish support), ToInitials, Reverse. |
FormatExtensions | ToSnakeCase, ToKebabCase, RemoveDiacritics. |
GenerationExtensions | Secure Random String & Password generation. |
ConversionExtensions | Safe type conversions (ToIntOrNull, To<T>). |
CasingExtensions | ToTitleCase, ToInvariantLower, ToInvariantUpper. |
PaddingExtensions | PadLeftWith, PadRightWith, PadBothWith (Center alignment). |
LengthExtensions | Fluent length checks: LongerThan, ShorterThan, IsLengthBetween. |
RegexExtensions | Safe Regex matching and extraction with Timeouts. |
DateParsingExtensions | Detect if string contains a valid date. |
Contributions and suggestions are welcome. Please open an issue or submit a pull request.
This project is licensed under the MIT License.
2025 Elmin Alirzayev / Easy Code Tools