C# Класс Yea.DataTypes.ExtensionMethods.StringExtensions

String and StringBuilder extensions
Показать файл Открыть проект

Открытые методы

Метод Описание
AlphaCharactersOnly ( this input ) : string

Keeps only alpha characters

AlphaNumericOnly ( this input ) : string

Keeps only alphanumeric characters

AppendLineFormat ( this builder, string format ) : StringBuilder

Does an AppendFormat and then an AppendLine on the StringBuilder

Center ( this input, int length, string padding = " " ) : string

Centers the input string (if it's longer than the length) and pads it using the padding string

Encode ( this input, Encoding originalEncodingUsing = null, Encoding encodingUsing = null ) : string

Converts a string to a string of another encoding

ExpandTabs ( this input, int tabSize = 4 ) : string

Expands tabs and replaces them with spaces

FilterOutText ( this input, string filter ) : string

Removes the filter text from the input.

FormatString ( this input ) : string

Formats a string based on the key/value pairs that are sent in

FormatString ( this input, object Object, string startSeperator = "{", string endSeperator = "}" ) : string

Formats a string based on the object's properties

FormatString ( this input, string format, IStringFormatter provider = null ) : string

Formats a string based on a format string passed in. The default formatter uses the following format: # = digits @ = alpha characters \ = escape char

FromBase64 ( this input ) : byte[]

Converts base 64 string to a byte array

FromBase64 ( this input, Encoding encodingUsing ) : string

Converts base 64 string based on the encoding passed in

IsAnagram ( this input1, string input2 ) : bool

Determines if the two strings are anagrams or not

IsCreditCard ( this creditCardNumber ) : bool

Checks if a credit card number is valid

IsUnicode ( this input ) : bool

Determines if a string is unicode

KeepFilterText ( this input, string filter ) : string

Removes everything that is not in the filter text from the input.

Left ( this input, int length ) : string

Gets the first x number of characters from the left hand side

MaskLeft ( this input, int endPosition = 4, char mask = '#' ) : string

Masks characters to the left ending at a specific character

MaskRight ( this input, int startPosition = 4, char mask = '#' ) : string

Masks characters to the right starting at a specific character

NextSequence ( this sequence, char min = ' ', char max = '~' ) : string

Function that is useful for generating a string in a series. so a becomes b, b becomes c, etc. and after hitting the max character, it goes to two characters (so ~ becomes aa, then ab, ac, etc).

NumberTimesOccurs ( this input, string match ) : int

returns the number of times a string occurs within the text

NumericOnly ( this input, bool keepNumericPunctuation = true ) : string

Keeps only numeric characters

Pluralize ( this word, CultureInfo culture = null ) : string

Pluralizes a word

RegexFormat ( this input, string format, string outputFormat, RegexOptions options = RegexOptions.None ) : string

Uses a regex to format the input string

RemoveExtraSpaces ( this input ) : string

Removes multiple spaces from a string and replaces it with a single space

Reverse ( this input ) : string

Reverses a string

Right ( this input, int length ) : string

Gets the last x number of characters from the right hand side

Singularize ( this word, CultureInfo culture = null ) : string

Singularizes a word

StripIllegalXml ( this content ) : string

Strips illegal characters for XML content

StripLeft ( this input, string characters = " " ) : string

Strips out any of the characters specified starting on the left side of the input string (stops when a character not in the list is found)

StripRight ( this input, string characters = " " ) : string

Strips out any of the characters specified starting on the right side of the input string (stops when a character not in the list is found)

ToBase64 ( this input, Encoding originalEncodingUsing = null ) : string

Converts from the specified encoding to a base 64 string

ToByteArray ( this input, Encoding encodingUsing = null ) : byte[]

Converts a string to a byte array

ToFirstCharacterUpperCase ( this input ) : string

Takes the first character of an input string and makes it uppercase

ToSentenceCapitalize ( this input ) : string

Capitalizes each sentence within the string

ToTitleCase ( this input ) : string

Capitalizes the first character of each word

Приватные методы

Метод Описание
LevenshteinDistance ( this value1, string value2 ) : int

Описание методов

AlphaCharactersOnly() публичный статический Метод

Keeps only alpha characters
public static AlphaCharactersOnly ( this input ) : string
input this Input string
Результат string

AlphaNumericOnly() публичный статический Метод

Keeps only alphanumeric characters
public static AlphaNumericOnly ( this input ) : string
input this Input string
Результат string

AppendLineFormat() публичный статический Метод

Does an AppendFormat and then an AppendLine on the StringBuilder
public static AppendLineFormat ( this builder, string format ) : StringBuilder
builder this Builder object
format string Format string
Результат StringBuilder

Center() публичный статический Метод

Centers the input string (if it's longer than the length) and pads it using the padding string
public static Center ( this input, int length, string padding = " " ) : string
input this
length int
padding string
Результат string

Encode() публичный статический Метод

Converts a string to a string of another encoding
public static Encode ( this input, Encoding originalEncodingUsing = null, Encoding encodingUsing = null ) : string
input this input string
originalEncodingUsing System.Text.Encoding The type of encoding the string is currently using (defaults to ASCII)
encodingUsing System.Text.Encoding The type of encoding the string is converted into (defaults to UTF8)
Результат string

ExpandTabs() публичный статический Метод

Expands tabs and replaces them with spaces
public static ExpandTabs ( this input, int tabSize = 4 ) : string
input this Input string
tabSize int Number of spaces
Результат string

FilterOutText() публичный статический Метод

Removes the filter text from the input.
public static FilterOutText ( this input, string filter ) : string
input this Input text
filter string Regex expression of text to filter out
Результат string

FormatString() публичный статический Метод

Formats a string based on the key/value pairs that are sent in
public static FormatString ( this input ) : string
input this Input string
Результат string

FormatString() публичный статический Метод

Formats a string based on the object's properties
public static FormatString ( this input, object Object, string startSeperator = "{", string endSeperator = "}" ) : string
input this Input string
Object object Object to use to format the string
startSeperator string Seperator character/string to use to describe the start of the property name
endSeperator string Seperator character/string to use to describe the end of the property name
Результат string

FormatString() публичный статический Метод

Formats a string based on a format string passed in. The default formatter uses the following format: # = digits @ = alpha characters \ = escape char
public static FormatString ( this input, string format, IStringFormatter provider = null ) : string
input this Input string
format string Format of the output string
provider IStringFormatter String formatter provider (defaults to GenericStringFormatter)
Результат string

FromBase64() публичный статический Метод

Converts base 64 string to a byte array
public static FromBase64 ( this input ) : byte[]
input this Input string
Результат byte[]

FromBase64() публичный статический Метод

Converts base 64 string based on the encoding passed in
public static FromBase64 ( this input, Encoding encodingUsing ) : string
input this Input string
encodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
Результат string

IsAnagram() публичный статический Метод

Determines if the two strings are anagrams or not
public static IsAnagram ( this input1, string input2 ) : bool
input1 this Input 1
input2 string Input 2
Результат bool

IsCreditCard() публичный статический Метод

Checks if a credit card number is valid
public static IsCreditCard ( this creditCardNumber ) : bool
creditCardNumber this Number to check
Результат bool

IsUnicode() публичный статический Метод

Determines if a string is unicode
public static IsUnicode ( this input ) : bool
input this Input string
Результат bool

KeepFilterText() публичный статический Метод

Removes everything that is not in the filter text from the input.
public static KeepFilterText ( this input, string filter ) : string
input this Input text
filter string Regex expression of text to keep
Результат string

Left() публичный статический Метод

Gets the first x number of characters from the left hand side
public static Left ( this input, int length ) : string
input this Input string
length int x number of characters to return
Результат string

MaskLeft() публичный статический Метод

Masks characters to the left ending at a specific character
public static MaskLeft ( this input, int endPosition = 4, char mask = '#' ) : string
input this Input string
endPosition int End position (counting from the left)
mask char Mask character to use
Результат string

MaskRight() публичный статический Метод

Masks characters to the right starting at a specific character
public static MaskRight ( this input, int startPosition = 4, char mask = '#' ) : string
input this Input string
startPosition int Start position (counting from the left)
mask char Mask character to use
Результат string

NextSequence() публичный статический Метод

Function that is useful for generating a string in a series. so a becomes b, b becomes c, etc. and after hitting the max character, it goes to two characters (so ~ becomes aa, then ab, ac, etc).
public static NextSequence ( this sequence, char min = ' ', char max = '~' ) : string
sequence this Current sequence
min char Min character
max char Max character
Результат string

NumberTimesOccurs() публичный статический Метод

returns the number of times a string occurs within the text
public static NumberTimesOccurs ( this input, string match ) : int
input this input text
match string The string to match (can be regex)
Результат int

NumericOnly() публичный статический Метод

Keeps only numeric characters
public static NumericOnly ( this input, bool keepNumericPunctuation = true ) : string
input this Input string
keepNumericPunctuation bool Determines if decimal places should be kept
Результат string

Pluralize() публичный статический Метод

Pluralizes a word
public static Pluralize ( this word, CultureInfo culture = null ) : string
word this Word to pluralize
culture System.Globalization.CultureInfo Culture info used to pluralize the word (defaults to current culture)
Результат string

RegexFormat() публичный статический Метод

Uses a regex to format the input string
public static RegexFormat ( this input, string format, string outputFormat, RegexOptions options = RegexOptions.None ) : string
input this Input string
format string Regex string used to
outputFormat string Output format
options RegexOptions Regex options
Результат string

RemoveExtraSpaces() публичный статический Метод

Removes multiple spaces from a string and replaces it with a single space
public static RemoveExtraSpaces ( this input ) : string
input this Input string
Результат string

Reverse() публичный статический Метод

Reverses a string
public static Reverse ( this input ) : string
input this Input string
Результат string

Right() публичный статический Метод

Gets the last x number of characters from the right hand side
public static Right ( this input, int length ) : string
input this Input string
length int x number of characters to return
Результат string

Singularize() публичный статический Метод

Singularizes a word
public static Singularize ( this word, CultureInfo culture = null ) : string
word this Word to singularize
culture System.Globalization.CultureInfo Culture info used to singularize the word (defaults to current culture)
Результат string

StripIllegalXml() публичный статический Метод

Strips illegal characters for XML content
public static StripIllegalXml ( this content ) : string
content this Content
Результат string

StripLeft() публичный статический Метод

Strips out any of the characters specified starting on the left side of the input string (stops when a character not in the list is found)
public static StripLeft ( this input, string characters = " " ) : string
input this Input string
characters string Characters to string (defaults to a space)
Результат string

StripRight() публичный статический Метод

Strips out any of the characters specified starting on the right side of the input string (stops when a character not in the list is found)
public static StripRight ( this input, string characters = " " ) : string
input this Input string
characters string Characters to string (defaults to a space)
Результат string

ToBase64() публичный статический Метод

Converts from the specified encoding to a base 64 string
public static ToBase64 ( this input, Encoding originalEncodingUsing = null ) : string
input this Input string
originalEncodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
Результат string

ToByteArray() публичный статический Метод

Converts a string to a byte array
public static ToByteArray ( this input, Encoding encodingUsing = null ) : byte[]
input this input string
encodingUsing System.Text.Encoding The type of encoding the string is using (defaults to UTF8)
Результат byte[]

ToFirstCharacterUpperCase() публичный статический Метод

Takes the first character of an input string and makes it uppercase
public static ToFirstCharacterUpperCase ( this input ) : string
input this Input string
Результат string

ToSentenceCapitalize() публичный статический Метод

Capitalizes each sentence within the string
public static ToSentenceCapitalize ( this input ) : string
input this Input string
Результат string

ToTitleCase() публичный статический Метод

Capitalizes the first character of each word
public static ToTitleCase ( this input ) : string
input this Input string
Результат string