https://github.com/arnab-developer/arc.stringsanitizer
This library is to sanitize and unsanitize string
https://github.com/arnab-developer/arc.stringsanitizer
csharp dotnet nuget
Last synced: 3 months ago
JSON representation
This library is to sanitize and unsanitize string
- Host: GitHub
- URL: https://github.com/arnab-developer/arc.stringsanitizer
- Owner: Arnab-Developer
- License: mit
- Created: 2021-08-14T09:46:03.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-25T04:55:04.000Z (over 1 year ago)
- Last Synced: 2025-01-17T02:24:08.362Z (5 months ago)
- Topics: csharp, dotnet, nuget
- Language: C#
- Homepage:
- Size: 47.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# String sanitizer
This library is to sanitize and unsanitize string.
Suppose you are working on a string and there are some special chars in it for that you can't work with that string. Then you need to replace those special chars to anything simple chars with which you can work with the string. Also when you are done then you may need to revert them to get back to the previous state of the string.
This library helps you to do that. You can create a config with details like which special chars need to be replaced with which simple chars and call the sanitize method. When your work with the string will complete then you can revert all the sanitization by calling the unsanitize method of this library.
You can get this from [NuGet](https://www.nuget.org/packages/Arc.StringSanitizer).
## How to use
To sanitize a string:
```csharp
var unsanitizedString = "sample test with special char. some more char";var sanitizerConfigs = new List()
{
new SanitizerConfig("special char", "[sc]"),
new SanitizerConfig(" ", "[html space]")
};var sanitizedString = unsanitizedString.Sanitize(sanitizerConfigs);
Console.WriteLine(sanitizedString);// Output: sample test with [sc]. some more [html space] char
```To unsanitize a string:
```csharp
var sanitizedString = "sample test with [sc]. some more [html space] char";var sanitizerConfigs = new List()
{
new SanitizerConfig("special char", "[sc]"),
new SanitizerConfig(" ", "[html space]")
};var unsanitizedString = sanitizedString.Unsanitize(sanitizerConfigs);
Console.WriteLine(unsanitizedString);// Output: sample test with special char. some more char
```