| name | Zakira.Imprint.Sample - String Utilities Library |
| description | Comprehensive guide for AI assistants on using the StringExtensions and StringHelper APIs |
| version | 1.0.0 |
| author | Imprint |
Zakira.Imprint.Sample - String Utilities
This skill teaches you how to use the Zakira.Imprint.Sample NuGet package, which provides string manipulation utilities via the StringExtensions and StringHelper classes.
Namespace
All types are in the Zakira.Imprint.Sample.WithCode namespace:
using Zakira.Imprint.Sample.WithCode;
StringExtensions (Extension Methods)
These are extension methods on string. After adding the using directive, call them directly on any string instance.
Slugify
Converts a string to a URL-friendly slug (lowercase, hyphens, no special chars).
"Hello World! This is C#".Slugify()
"Café Résumé".Slugify()
" Multiple Spaces ".Slugify()
Truncate
Truncates to a maximum length with a configurable suffix.
"Hello World".Truncate(8)
"Hello World".Truncate(8, "~")
"Hi".Truncate(10)
Mask
Masks the middle portion of a string, keeping visible characters at start and end.
"1234567890".Mask(2, 2)
"SensitiveData".Mask(3, 3)
"1234567890".Mask(2, 2, '#')
ToTitleCase
Converts to Title Case (first letter of each word capitalized).
"hello world example".ToTitleCase()
"ALL CAPS INPUT".ToTitleCase()
RemoveDiacritics
Strips accent marks from characters.
"café résumé".RemoveDiacritics()
"naïve über".RemoveDiacritics()
ToCamelCase
Converts to camelCase from any word-separated format.
"hello world example".ToCamelCase()
"some-kebab-case".ToCamelCase()
"SOME_SCREAMING_SNAKE".ToCamelCase()
ToSnakeCase
Converts to snake_case.
"Hello World".ToSnakeCase()
"camelCaseExample".ToSnakeCase()
"PascalCaseInput".ToSnakeCase()
Reverse
Reverses the characters in a string.
"Hello".Reverse()
"12345".Reverse()
WordCount
Counts the number of whitespace-separated words.
"Hello world, this is a test".WordCount()
" ".WordCount()
StringHelper (Static Methods)
These are static methods. Call them via StringHelper.MethodName(...).
MaskEmail
Smart email masking that preserves the domain.
StringHelper.MaskEmail("john.doe@example.com")
StringHelper.MaskEmail("ab@test.com")
StringHelper.MaskEmail("admin@corp.com", 3)
MaskCreditCard
Masks all but the last 4 digits of a credit card number, re-formatted with hyphens.
StringHelper.MaskCreditCard("4111-1111-1111-1111")
StringHelper.MaskCreditCard("4111111111111111")
ShortHash
Generates a deterministic short hash (MD5-based hex) for a string input.
StringHelper.ShortHash("hello world")
StringHelper.ShortHash("hello world", 12)
Use cases: cache keys, deduplication tokens, short identifiers.
GenerateRandom
Generates a random alphanumeric string of the desired length.
StringHelper.GenerateRandom(12)
StringHelper.GenerateRandom(6, "0123456789")
IsValidEmail
Basic email format validation.
StringHelper.IsValidEmail("user@example.com")
StringHelper.IsValidEmail("not-an-email")
StringHelper.IsValidEmail("")
GetInitials
Extracts uppercase initials from a name.
StringHelper.GetInitials("John Michael Doe")
StringHelper.GetInitials("Alice")
StringHelper.GetInitials("A B C D E", 2)
Common Patterns
Preparing user-generated content for URL slugs
var title = "My Blog Post: A Café Story!";
var slug = title.Slugify();
var url = $"/posts/{slug}";
Displaying masked sensitive data in logs
var email = "customer@company.com";
var card = "4111-1111-1111-1111";
Console.WriteLine($"Email: {StringHelper.MaskEmail(email)}");
Console.WriteLine($"Card: {StringHelper.MaskCreditCard(card)}");
Converting between naming conventions
var input = "myPropertyName";
var snake = input.ToSnakeCase();
var camel = snake.ToCamelCase();
var slug = input.Slugify();
Error Handling
- All extension methods handle
null and empty strings gracefully (return empty string or the input).
Truncate throws ArgumentOutOfRangeException if maxLength < 0.
Mask throws ArgumentOutOfRangeException if visibleStart or visibleEnd are negative.
ShortHash throws ArgumentNullException if input is null, and ArgumentOutOfRangeException if length is out of range.
Source Package
- Package: Zakira.Imprint.Sample
- Installed Via: NuGet (provides both the DLL and these skill files)
- Skill Location:
.github/skills/