https://github.com/technobre/powerutils.text
Helpers, extensions and utilities for manipulating strings
https://github.com/technobre/powerutils.text
csharp dotnet string-manipulation text-manipulation
Last synced: about 1 year ago
JSON representation
Helpers, extensions and utilities for manipulating strings
- Host: GitHub
- URL: https://github.com/technobre/powerutils.text
- Owner: TechNobre
- License: mit
- Created: 2021-07-17T20:33:44.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-11T00:20:02.000Z (about 1 year ago)
- Last Synced: 2025-04-30T15:47:52.897Z (about 1 year ago)
- Topics: csharp, dotnet, string-manipulation, text-manipulation
- Language: C#
- Homepage: https://www.nuget.org/packages/PowerUtils.Text/
- Size: 217 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# PowerUtils.Text

***Helpers, extensions and utilities for manipulating strings***

[](https://dashboard.stryker-mutator.io/reports/github.com/TechNobre/PowerUtils.Text/main)
[](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.Text)
[](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.Text)
[](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.Text)
[](https://sonarcloud.io/summary/new_code?id=TechNobre_PowerUtils.Text)
[](https://www.nuget.org/packages/PowerUtils.Text)
[](https://www.nuget.org/packages/PowerUtils.Text)
[](https://github.com/TechNobre/PowerUtils.Text/blob/main/LICENSE)
- [Support to ](#support-to-)
- [How to use ](#how-to-use-)
- [Install NuGet package ](#install-nuget-package-)
- [TextExtensions ](#textextensions-)
- [string.CleanExtraSpaces(); ](#stringcleanextraspaces-)
- [string.CleanExtraLineBreak(); ](#stringcleanextralinebreak-)
- [string.CleanExtraLineBreakAndLineBreak(); ](#stringcleanextralinebreakandlinebreak-)
- [string.EmptyOrWhiteSpaceToNull(); ](#stringemptyorwhitespacetonull-)
- [string.CompressText(maxLength); ](#stringcompresstextmaxlength-)
- [string.Truncate(maxLength); ](#stringtruncatemaxlength-)
- [string.CapitalizeName(); ](#stringcapitalizename-)
- [string.CleanSpecialCharacters(substitute = ""); ](#stringcleanspecialcharacterssubstitute---)
- [string.UppercaseFirst(); ](#stringuppercasefirst-)
- [string.LowercaseFirst(); ](#stringlowercasefirst-)
- [string.ToSnakeCase(); ](#stringtosnakecase-)
- [TextExtensions ](#textextensions--1)
- [string.IsEmail(); ](#stringisemail-)
- [string.CombineURL(); ](#stringcombineurl-)
- [object.ToQueryString(); ](#objecttoquerystring-)
- [Contribution ](#contribution-)
## Support to
- .NET 9.0
- .NET 8.0
- .NET 7.0
- .NET 6.0
- .NET 5.0
- .NET 3.1
### Install NuGet package
This package is available through Nuget Packages: https://www.nuget.org/packages/PowerUtils.Text
**Nuget**
```bash
Install-Package PowerUtils.Text
```
**.NET CLI**
```
dotnet add package PowerUtils.Text
```
#### string.CleanExtraSpaces();
Clean extra spaces. Replace tabs to one space and double spaces to one space
```csharp
// result = "Hello world!!!"
var result = " Hello world!!! ".CleanExtraSpaces();
```
#### string.CleanExtraLineBreak();
Clean extra line breaks. Replace double line breaks to one line break
```csharp
// result = "Hello\r\nWorld!!!"
var result = "Hello\r\n\r\n\r\nWorld!!!".CleanExtraLineBreak();
```
#### string.CleanExtraLineBreakAndLineBreak();
Clean extra spaces, override tabs to one space, double spaces to one space and double line breaks to one line break
```csharp
// result = "Hello\r\nWorld!!!"
var result = " Hello \r\n\r\n\r\n World!!! ".CleanExtraLineBreakAndLineBreak();
```
#### string.EmptyOrWhiteSpaceToNull();
Convert a string with empty or white spaces to null
```csharp
// result = null
var result = " ".EmptyOrWhiteSpaceToNull();
```
#### string.CompressText(maxLength);
Compress text if greater the max length
```csharp
// result = "Hell..."
var result = "Hello world!!!".CompressText(5);
```
#### string.Truncate(maxLength);
Truncate text if greater the max length
```csharp
// result = "Hello"
var result = "Hello world!!!".Truncate(5);
```
#### string.CapitalizeName();
Capitalize the people amd company names
```csharp
// result = "Nelson Nobre"
var result = "nelson nobre".CapitalizeName();
```
#### string.CleanSpecialCharacters(substitute = "");
Capitalize the people amd company names
```csharp
// result1 = "HelloWorld"
var result1 = "Hello World!!!".CleanSpecialCharacters();
// result2 = "Hello-World"
var result2 = "Hello World".CleanSpecialCharacters("-");
```
#### string.UppercaseFirst();
Uppercase the first character
```csharp
// result = "Hello world!!!"
var result = "hello world!!!".UppercaseFirst();
```
#### string.LowercaseFirst();
Uppercase the first character
```csharp
// result = "hello world!!!"
var result = "Hello world!!!".UppercaseFirst();
```
#### string.ToSnakeCase();
Convert a text to snake case format
```csharp
// result = "test_snake_case"
var result = "TestSnakeCase".ToSnakeCase();
```
#### string.IsEmail();
Check if the input is an email
```csharp
// result = true
var result = "nelson@fake.com".IsEmail();
```
#### string.CombineURL();
Check if the input is an email
```csharp
// result = http://localhost:8080/clients/photos
var result = "http://localhost:8080".CombineURL("clients", "photos");
```
#### object.ToQueryString();
Convert an object to a QueryString.
```csharp
object parameters = new
{
Name = "Nelson",
Age = 12,
IsValide = true
};
// result = ?Name=Nelson&Age=12&IsValide=True
var result = parameters.ToQueryString();
```
If you have any questions, comments, or suggestions, please open an [issue](https://github.com/TechNobre/PowerUtils.Text/issues/new/choose) or create a [pull request](https://github.com/TechNobre/PowerUtils.Text/compare)