{"id":24524197,"url":"https://github.com/bytedev/bytedev.strings","last_synced_at":"2025-04-14T12:53:58.920Z","repository":{"id":134773078,"uuid":"259890385","full_name":"ByteDev/ByteDev.Strings","owner":"ByteDev","description":"Library of extended string related functionality.","archived":false,"fork":false,"pushed_at":"2024-10-10T10:24:21.000Z","size":195,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T09:16:12.495Z","etag":null,"topics":["csharp","dotnet-standard","extension-methods","string","tostring"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ByteDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-04-29T10:07:13.000Z","updated_at":"2024-10-10T10:24:25.000Z","dependencies_parsed_at":"2024-01-10T07:48:50.639Z","dependency_job_id":"2e39fabf-30a0-4ba5-8489-33f24ad9b607","html_url":"https://github.com/ByteDev/ByteDev.Strings","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDev%2FByteDev.Strings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDev%2FByteDev.Strings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDev%2FByteDev.Strings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ByteDev%2FByteDev.Strings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ByteDev","download_url":"https://codeload.github.com/ByteDev/ByteDev.Strings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248885518,"owners_count":21177626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet-standard","extension-methods","string","tostring"],"created_at":"2025-01-22T04:18:48.404Z","updated_at":"2025-04-14T12:53:58.895Z","avatar_url":"https://github.com/ByteDev.png","language":"C#","readme":"[![Build status](https://ci.appveyor.com/api/projects/status/github/bytedev/ByteDev.Strings?branch=master\u0026svg=true)](https://ci.appveyor.com/project/bytedev/ByteDev-Strings/branch/master)\n[![NuGet Package](https://img.shields.io/nuget/v/ByteDev.Strings.svg)](https://www.nuget.org/packages/ByteDev.Strings)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/ByteDev/ByteDev.Strings/blob/master/LICENSE)\n\n# ByteDev.Strings\n\nLibrary of extended string related functionality.\n\n## Installation\n\nByteDev.Strings has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.\n\nByteDev.Strings is hosted as a package on nuget.org.  To install from the Package Manager Console in Visual Studio run:\n\n`Install-Package ByteDev.Strings`\n\nFurther details can be found on the [nuget page](https://www.nuget.org/packages/ByteDev.Strings/).\n\n## Release Notes\n\nReleases follow semantic versioning.\n\nFull details of the release notes can be viewed on [GitHub](https://github.com/ByteDev/ByteDev.Strings/blob/master/docs/RELEASE-NOTES.md).\n\n## Usage\n\n### String Extensions\n\nTo use any of the extension method reference the `ByteDev.Strings` namespace.\n\nString extension methods:\n\n- ContainsAll\n- ContainsAny\n- ContainsOnly\n- ContainsIgnoreCase\n- ContainsWhiteSpace\n- CountOccurrences\n- DetectNewLineType\n- EnsureStartsWith\n- EnsureEndsWith\n- FormatWith\n- GetEndNewLine\n- InsertBeforeUpperCase\n- IsAscii\n- IsDateTime\n- IsDigit\n- IsDigits\n- IsEmpty\n- IsEmailAddress\n- IsFalse\n- IsGuid\n- IsHttpUrl\n- IsIpAddress\n- IsLengthBetween\n- IsLetters\n- IsLowerCase\n- IsNullOrEmpty\n- IsNullOrWhitespace\n- IsNumeric\n- IsPhoneNumber\n- IsUpperCase\n- IsUri\n- IsTime\n- IsTrue\n- IsXml\n- Left\n- LeftWithEllipsis\n- LeftWithInnerEllipsis\n- NormalizeNewLinesToUnix\n- NormalizeNewLinesToWindows\n- Pluralize\n- Remove\n- RemoveBracketedText\n- RemoveEndNewLine\n- RemoveEndsWith\n- RemoveLeadingZeros\n- ReplaceMultiOccurrences\n- RemoveNonDigits\n- RemoveStartsWith\n- RemoveWhiteSpace\n- Repeat\n- ReplaceFirst\n- ReplaceLast\n- ReplaceToken\n- Reverse\n- Right\n- SafeGetChar\n- SafeLength\n- SafeSubstring\n- ToBool\n- ToBoolExtended\n- ToBoolOrDefault\n- ToByteArray\n- ToSequence\n- ToEnum\n- ToGuid\n- ToInt32\n- ToInt32OrDefault\n- ToInt64\n- ToInt64OrDefault\n- ToKeyValuePair\n- ToLines\n- ToLinesList\n- ToMemoryStream\n- ToUri\n- ToTitleCase\n- Wrap\n\nStringBuilder extension methods:\n\n- AppendIfEmpty\n- AppendIfNotEmpty\n- AppendLineIfEmpty\n- AppendLineIfNotEmpty\n- AppendLines\n- AppendValues\n- IsEmpty\n\n---\n\n### CaseConverter\n\n`CaseConverter` can be used to change the case of different strings.\n\nReference namespace: `ByteDev.Strings.Case`.\n\n`CaseConverter` has the following methods:\n- ToCamelCase\n- ToKebabCase\n- ToPascalCase\n- ToSnakeCase\n- ToSnakeUpperCase\n\n```csharp\nstring s1 = CaseConverter.ToCamelCase(\"snake_case\", CaseType.SnakeCase);   // \"snakeCase\"\n\nstring s2 = CaseConverter.ToPascalCase(\"kebab-case\", CaseType.KebabCase);  // \"KebabCase\"\n\nbool isPascalCase = s2.IsPascalCase();   // true\n```\n\nThere are also a number of case related string extension methods:\n\n- IsCamelCase\n- IsKebabCase\n- IsPascalCase\n- IsSnakeCase\n- IsSnakeUpperCase\n- IsCaseType\n\n---\n\n### StringCommands\n\nVarious `StringCommands` are included that encapsulate different string operations.\n\nReference namespace: `ByteDev.Strings.StringCommands`.\n\n```csharp\nvar c1 = new CaseToLowerCommand().SetValue(\"John Smith\");\nvar c2 = new CopyPasteCommand(0, 4, 0).SetValue(\"John Smith\");\n\nIStringCommandInvoker invoker = new StringCommandInvoker();\n\ninvoker.SetCommands(c1, c2);\ninvoker.Invoke();\n\n// c1.Result == \"john smith\" \n// c2.Result == \"JohnJohn Smith\"\n```\n\nCommands can also be chained together using the `StringChainedCommand`:\n\n```csharp\n// Note: we don't have to call SetValue on each command just on StringChainedCommand\n// as this will provide the initial value.\n\nvar commands = new List\u003cStringCommand\u003e\n{\n    new CaseToLowerCommand(),\n    new InsertCommand(100, \" lives in England.\"),\n    new CutPasteCommand(5, 5, 0)\n};\n\nvar c1 = new StringChainedCommand(commands).SetValue(\"John Smith\");\n\nIStringCommandInvoker invoker = new StringCommandInvoker();\n\ninvoker.SetCommands(c1);\ninvoker.Invoke();\n\n// command.Result == \"smithjohn  lives in England.\"\n```\n\n---\n\n### ToStringBuilder\n\nThe assembly also contains the type `ToStringBuilder` to help return string representations of an object when overriding it's `ToString` method.\n\nReference namespace: `ByteDev.Strings`.\n\n```csharp\npublic class MyClass\n{\n    public string Name =\u003e \"John\";\n\n    public string Age =\u003e null;\n\n    public IEnumerable\u003cstring\u003e Address =\u003e new List\u003cstring\u003e\n    {\n        \"123 Highstreet\",\n        \"London\",\n        \"UK\"\n    };\n\n    public override string ToString()\n    {\n        return new ToStringBuilder()\n            .WithNullValue(\"\u003cnull\u003e\")\n            .WithStringQuoteChar('\\'')\n            .With(nameof(Name), Name)\n            .With(nameof(Age), Age)\n            .With(nameof(Address), Address)\n            .Build();\n    }\n}\n\n// ...\nstring s = new MyClass().ToString();\n\n// s == \"Name: 'John', Age: \u003cnull\u003e, Address: { '123 Highstreet', 'London', 'UK' }\"\n```\n\n---\n\n### Masker\n\nUse the `Masker` type to help mask different types of strings.\n\nReference namespace: `ByteDev.Strings.Masking`.\n\n```csharp\n// Initialize Masker type\n\nvar options = new MaskerOptions\n{\n    MaskChar = '#',\n    MaskSpace = true\n};\n\nvar masker = new Masker(options);\n```\n\n```csharp\n// Mask a payment card number\n\nstring card = masker.PaymentCard(\"4111111111111111\");\n\n// card == \"############1111\"\n```\n\n```csharp\n// Mask an email address\n\nstring email = masker.EmailAddress(\"john.smith@gmail.co.uk\");\n\n// email == \"j#########@#####.co.uk\"\n```\n\n```csharp\n// Mask a custom string\n\nstring custom = masker.Custom(\"12345\", 1, 2);\n\n// custom == \"1##45\"\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytedev%2Fbytedev.strings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytedev%2Fbytedev.strings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytedev%2Fbytedev.strings/lists"}