New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

TextUtilities

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

TextUtilities

A fluent library for advanced text manipulation, including removing spaces, normalizing Persian text, creating URL slugs, and more.

Source
nugetNuGet
Version
1.0.2
Version published
Maintainers
1
Created
Source

📝TextUtilities

License: MIT NuGet NuGet Downloads .NET Version

TextUtilities is a fluent, lightweight, and powerful .NET library designed for advanced text manipulation. Whether you're normalizing Persian text, creating URL-friendly slugs, formatting text with HTML or Markdown, or performing complex string operations, TextUtilities offers an intuitive Fluent API to make your code clean and efficient.

✨ Features

  • Fluent API: Chain methods for readable and maintainable code.
  • Multilingual Support: Normalize Persian/Arabic characters (e.g., converting ي to ی or ك to ک).
  • Text Formatting: Add HTML/Markdown bold tags, prefixes, or perform regex-based replacements.
  • Advanced Text Operations: Create URL slugs, reverse text or words, count words, and more.
  • Lightweight: Minimal dependencies, optimized for performance.
  • Reliable: Fully tested with xUnit to ensure quality and stability.
  • Cross-Platform: Built for .NET 9.0, compatible with modern .NET applications.

📦 Installation

To use TextUtilities in your project, install it via NuGet:

dotnet add package TextUtilities --version 1.0.1

Or, if you prefer using the Package Manager Console:

Install-Package TextUtilities -Version 1.0.1

🚀Quick Start

Get started with TextUtilities in just a few lines of code:

using TextUtilities;

string result = new TextUtility("Hello World!")
    .RemoveSpaces()
    .ToBold()
    .AddPrefix("Output: ")
    .Build();

Console.WriteLine(result);
// Output: Output: <b>HelloWorld!</b>

🛠️Usage Examples

Below are some practical examples to demonstrate the power of TextUtilities:

  • Normalizing Persian Text
using TextUtilities;

string result = new TextUtility("hello world")
    .NormalizePersian()
    .ToUpperCase()
    .Build();

Console.WriteLine(result);
  • Creating a URL-Friendly Slug
using TextUtilities;

string result = new TextUtility("Hello World! @#$")
    .ToSlug()
    .Build();

Console.WriteLine(result);
// Output: hello-world
  • Chaining Multiple Operations
using TextUtilities;

string result = new TextUtility("This is a TEST string!")
    .ToLowerCase()
    .RemoveSpaces()
    .ToMarkdownBold()
    .ToSlug()
    .AddPrefix("Slug: ")
    .Build();

Console.WriteLine(result);
// Output: Slug: **thisisateststring**
  • Reversing Words and Counting
using TextUtilities;

string text = "Hello Beautiful World";
var utility = new TextUtility(text);

string reversed = utility.ReverseWords().Build();
int wordCount = utility.WordCount();

Console.WriteLine($"Reversed: {reversed}");
Console.WriteLine($"Word Count: {wordCount}");
// Output:
// Reversed: World Beautiful Hello
// Word Count: 3
  • Resetting Text
using TextUtilities;

var utility = new TextUtility("Hello World");
string modified = utility.ToSlug().Build(); // hello-world
string reset = utility.Reset().ToBold().Build(); // <b>Hello World</b>

Console.WriteLine($"Modified: {modified}");
Console.WriteLine($"Reset: {reset}");
// Output:
// Modified: hello-world
// Reset: <b>Hello World</b>
  • Regex Replacement
using TextUtilities;

string result = new TextUtility("Hello123World456")
    .ReplaceRegex("[0-9]+", "X")
    .Build();

Console.WriteLine(result);
// Output: HelloXWorldX

🧪Testing

TextUtilities is thoroughly tested using xUnit to ensure reliability. To run the tests locally:

  • Clone the repository:
git clone https://github.com/hheydarian/TextUtilities.git
  • Navigate to the project directory:
cd TextUtilities
  • Run the tests:
dotnet test

All 9+ unit tests should pass, covering key functionality.

🤝Contributing

We welcome contributions to make TextUtilities even better! To contribute:

  • Fork the repository.

  • Create a new branch:

git checkout -b feature/YourFeature
  • Make your changes and commit:
git commit -m 'Add some feature'
  • Push to your branch:
git push origin feature/YourFeature
  • Open a Pull Request on GitHub.

Please ensure your code follows the existing style, includes unit tests, and passes all checks.

📄License

This project is licensed under the MIT License (LICENSE). See the LICENSE file for details.

📭Contact & Support

  • Author: Hamed Heydarian

  • GitHub: hheydarian

  • NuGet: TextUtilities

  • Issues: Report bugs or suggest features on GitHub Issues

For questions or feedback, feel free to open an issue or reach out!

⭐Enjoying TextUtilities? Give it a star on GitHub!⭐

Thank you for using TextUtilities!🚀

Keywords

TextUtilities

FAQs

Package last updated on 24 Apr 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