{"id":17197180,"url":"https://github.com/thomaslevesque/nstring","last_synced_at":"2025-06-15T09:08:33.382Z","repository":{"id":10194781,"uuid":"12285617","full_name":"thomaslevesque/NString","owner":"thomaslevesque","description":"A collection of utilities for working with strings in .NET.","archived":false,"fork":false,"pushed_at":"2020-05-31T15:19:36.000Z","size":131,"stargazers_count":37,"open_issues_count":1,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-14T14:49:47.399Z","etag":null,"topics":["csharp","dotnet","extensions","string"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomaslevesque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-22T01:30:33.000Z","updated_at":"2025-05-07T06:35:18.000Z","dependencies_parsed_at":"2022-08-28T08:53:03.386Z","dependency_job_id":null,"html_url":"https://github.com/thomaslevesque/NString","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/thomaslevesque/NString","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FNString","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FNString/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FNString/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FNString/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomaslevesque","download_url":"https://codeload.github.com/thomaslevesque/NString/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FNString/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259949682,"owners_count":22936411,"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","extensions","string"],"created_at":"2024-10-15T01:55:39.807Z","updated_at":"2025-06-15T09:08:32.906Z","avatar_url":"https://github.com/thomaslevesque.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NString\n\n[![NuGet version](https://img.shields.io/nuget/v/NString.svg?logo=nuget)](https://www.nuget.org/packages/NString)\n[![AppVeyor build](https://img.shields.io/appveyor/ci/thomaslevesque/nstring.svg?logo=appveyor)](https://ci.appveyor.com/project/thomaslevesque/nstring)\n[![AppVeyor tests](https://img.shields.io/appveyor/tests/thomaslevesque/nstring.svg?logo=appveyor)](https://ci.appveyor.com/project/thomaslevesque/nstring/build/tests)\n\nA collection of utilities for working with strings in .NET.\n\n## StringTemplate\n\nThis class allows you to format values in a way similar to `String.Format`, but with named placeholders instead of numbered placeholders. The values to format are passed as a simple object (anonymous types are allowed of course). Format specifiers can be used in the same way as with `String.Format`. Here's an example:\n\n```csharp\nstatic void Main()\n{\n    var joe = new Person { Name = \"Joe\", DateOfBirth = new DateTime(1980, 6, 22) };\n    string text = StringTemplate.Format(\"{Name} was born on {DateOfBirth:D}\", joe);\n    Console.WriteLine(text); // Prints \"Joe was born on Sunday, 22 June 1980\"\n}\n```\n\n## Extension methods\n\n### IsNullOrEmpty, IsNullOrWhiteSpace, Join\n\nSame as the methods of the same name in the `String` class, but as extension methods, which makes them more convenient to use.\n\n```csharp\n\"\".IsNullOrEmpty() // true\n\" \".IsNullOrWhiteSpace() // true\nstring[] words = { \"hello\", \"world\" };\nwords.Join(\" \") // \"hello world\"\n```\n\n### GetLines\n\nLazily enumerates all lines in a string, making it easy to apply transformations to each line using Linq, for instance.\n\n```csharp\npublic string IndentAllLines(string text, string indent = \"    \")\n{\n    indentedLines = text.GetLines().Select(line =\u003e indent + line);\n    return string.Join(Environment.NewLine, indentedLines);\n}\n```\n\n### Left, Right\n\nReturns a string containing a specified number of characters from the left or right side of a string. These methods are shortcuts for common use cases of `Substring`, and behave in the same way (so they will throw if you try to get more characters than the length of the string).\n\n```csharp\n\"hello\".Left(2) // \"he\"\n\"hello\".Right(3) // \"llo\"\n```\n\n### Truncate\n\nReturns a string truncated to the specified number of characters. Similar to `Left`, but doesn't throw if the string is shorter than the specified length.\n\n```csharp\n\"hello\".Truncate(2) // \"he\"\n\"hello\".Truncate(8) // \"hello\"\n```\n\n### Capitalize\n\nCapitalizes a string by making its first character uppercase.\n\n```csharp\n\"hello\".Capitalize() // \"Hello\"\n```\n\n### MatchesWildcard\n\nChecks if a string matches the specified wildcard pattern (supports `*` for any number of characters, and `?` for exactly one character).\n\n```csharp\nif (fileName.MatchesWildCard(\"foobar.*.log\"))\n{\n    ...\n}\n```\n\n### Ellipsis\n\nTruncates a string to the specified length, replacing the extra characters with an ellipsis (three dots) or with the specified ellipsis string.\nThe specified length includes the length of the ellipsis.\n\n```csharp\n\"hello world\".Ellipsis(8) // \"hello...\"\n\"hello world\".Ellipsis(20) // \"hello world\"\n```\n\n### Contains\n\nChecks if the specified string contains the specified substring, using the specified comparison type (`Ordinal`, `CurrentCultureIgnoreCase`, etc).  Unlike the `String.StartsWith` and `String.EndsWith` methods, the `String.Contains` method doesn't have an overload to specify the comparison type; this extension method fills that gap.\n\n```csharp\n\"Hello World\".Contains(\"world\", StringComparison.CurrentCultureIgnoreCase) // true\n```\n\n### ReplaceAt\n\nReplaces a single character at the specified position with the specified replacement character.\n\n```csharp\n\"hello world\".ReplaceAt(0, 'j') // \"jello world\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2Fnstring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomaslevesque%2Fnstring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2Fnstring/lists"}