8000 GitHub - oqo0/extended-string: A set of extensions to the default String in .NET
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

oqo0/extended-string

Repository files navigation


A set of extensions to the default String in .NET which I was missing

Commit activity Code size Last commit


List of methods

  • Between - Returns a string between external strings or chars.
  • BetweenAll - Returns all strings between external strings or chars.
  • Center - Centers a string in a field of given width.
  • CountOccurence - Counts of a specified string in string.
  • IsEmptyOrWhitespace - Determines if string is empty or only consists of whitespaces.
  • LeftOf - Extracts a string left of a specified char \ string.
  • RightOf - Extracts a string right of a specified char \ string.
  • ReplaceAmount - Replaces a specified amount of string occurrence.
  • Reverse - Reverses a string.

Examples

You can find a variety of minimalistic examples in tests.

Between()

str = "#1$ #2$"
Console.WriteLine(
    str.Between('#', '$')
);

Result: "1"

BetweenAll()

str = "#1$ #2$"
Console.WriteLine(
    str.BetweenAll('#', '$')
);

Result: { "1", "2" }

Center()

str = "Text"
Console.WriteLine(
    str.Center(14)
);

Result: " Text "

CountOccurence()

str = "12 12 12"
Console.WriteLine(
    str.CountOccurence("12")
);

Result: 3

IsEmptyOrWhitespace()

str = "   "
Console.WriteLine(
    str.IsEmptyOrWhitespace()
);

Result: true

LeftOf()

str = "1234."
Console.WriteLine(
    str.LeftOf('4')
);

Result: 123

RightOf()

str = ".1234"
Console.WriteLine(
    str.RightOf('1')
);

Result: 234

ReplaceAmount()

str = "Some word for example"
Console.WriteLine(
    str.ReplaceAmount("o", 2)
);

Result: "Sme wrd for example"

Reverse()

str = "123"
Console.WriteLine(
    str.Reverse()
);

Result: "321"

About

A set of extensions to the default String in .NET

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

0