All Projects → thomaslevesque → NString

thomaslevesque / NString

Licence: Apache-2.0 license
A collection of utilities for working with strings in .NET.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to NString

Libchef
🍀 c++ standalone header-only basic library. || c++头文件实现无第三方依赖基础库
Stars: ✭ 178 (+423.53%)
Mutual labels:  string
Pupa
Simple micro templating
Stars: ✭ 231 (+579.41%)
Mutual labels:  string
string-combinations
A simple, low-memory footprint function to generate all string combinations from a series of characters.
Stars: ✭ 25 (-26.47%)
Mutual labels:  string
Str
A fast, solid and strong typed string manipulation library with multibyte support
Stars: ✭ 199 (+485.29%)
Mutual labels:  string
Php To String
Cast any php value into a string
Stars: ✭ 219 (+544.12%)
Mutual labels:  string
Case
String case utitility: convert, identify, flip, extend
Stars: ✭ 237 (+597.06%)
Mutual labels:  string
Algo Tree
Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
Stars: ✭ 166 (+388.24%)
Mutual labels:  string
man-in-the-middle
Modify requests, inject JavaScript and CSS into pages
Stars: ✭ 74 (+117.65%)
Mutual labels:  extensions
Superstring.py
A fast and memory-optimized string library for heavy-text manipulation in Python
Stars: ✭ 231 (+579.41%)
Mutual labels:  string
D365FONinjaDevTools
To make of you a Ninja Developer in Dynamics 365 For Finance and Operations
Stars: ✭ 70 (+105.88%)
Mutual labels:  extensions
Util
A collection of useful utility functions
Stars: ✭ 201 (+491.18%)
Mutual labels:  string
Codejam
Set of handy reusable .NET components that can simplify your daily work and save your time when you copy and paste your favorite helper methods and classes from one project to another
Stars: ✭ 217 (+538.24%)
Mutual labels:  string
Stringsimilarity.net
A .NET port of java-string-similarity
Stars: ✭ 242 (+611.76%)
Mutual labels:  string
Printj
📜 sprintf for JS
Stars: ✭ 182 (+435.29%)
Mutual labels:  string
Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+1264.71%)
Mutual labels:  string
Strman
🏗A Javascript string manipulation library.
Stars: ✭ 2,021 (+5844.12%)
Mutual labels:  string
Number To Words
Number to string standalone PHP library with i18n. Drivers for numbers and currency included.
Stars: ✭ 234 (+588.24%)
Mutual labels:  string
cs string
Header-only library providing unicode aware string support for C++
Stars: ✭ 91 (+167.65%)
Mutual labels:  string
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (+108.82%)
Mutual labels:  extensions
Superstring
A fast and memory-optimized string library for C++
Stars: ✭ 252 (+641.18%)
Mutual labels:  string

NString

NuGet version AppVeyor build AppVeyor tests

A collection of utilities for working with strings in .NET.

StringTemplate

This 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:

static void Main()
{
    var joe = new Person { Name = "Joe", DateOfBirth = new DateTime(1980, 6, 22) };
    string text = StringTemplate.Format("{Name} was born on {DateOfBirth:D}", joe);
    Console.WriteLine(text); // Prints "Joe was born on Sunday, 22 June 1980"
}

Extension methods

IsNullOrEmpty, IsNullOrWhiteSpace, Join

Same as the methods of the same name in the String class, but as extension methods, which makes them more convenient to use.

"".IsNullOrEmpty() // true
" ".IsNullOrWhiteSpace() // true
string[] words = { "hello", "world" };
words.Join(" ") // "hello world"

GetLines

Lazily enumerates all lines in a string, making it easy to apply transformations to each line using Linq, for instance.

public string IndentAllLines(string text, string indent = "    ")
{
    indentedLines = text.GetLines().Select(line => indent + line);
    return string.Join(Environment.NewLine, indentedLines);
}

Left, Right

Returns 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).

"hello".Left(2) // "he"
"hello".Right(3) // "llo"

Truncate

Returns 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.

"hello".Truncate(2) // "he"
"hello".Truncate(8) // "hello"

Capitalize

Capitalizes a string by making its first character uppercase.

"hello".Capitalize() // "Hello"

MatchesWildcard

Checks if a string matches the specified wildcard pattern (supports * for any number of characters, and ? for exactly one character).

if (fileName.MatchesWildCard("foobar.*.log"))
{
    ...
}

Ellipsis

Truncates a string to the specified length, replacing the extra characters with an ellipsis (three dots) or with the specified ellipsis string. The specified length includes the length of the ellipsis.

"hello world".Ellipsis(8) // "hello..."
"hello world".Ellipsis(20) // "hello world"

Contains

Checks 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.

"Hello World".Contains("world", StringComparison.CurrentCultureIgnoreCase) // true

ReplaceAt

Replaces a single character at the specified position with the specified replacement character.

"hello world".ReplaceAt(0, 'j') // "jello world"
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].